#Copy position and rotation of parent

10 messages · Page 1 of 1 (latest)

inland hemlock
#

I'm instantiating a rocket to be fired from a rocket launcher, but I'm having trouble with Transform3D. I want the rocket to get the same position and orientation of the rocket launcher, but the last line of my function doesn't seem to be doing anything at all

`func _spawn_rocket():
# Instantiate in the root of the scene
var instancedRocket = rocketPrefab.instantiate()
get_tree().get_root().add_child(instancedRocket)

# Move the rocket into its starting position and orientation
instancedRocket.transform = transform`
solid whale
#

theres a difference between local space and global space

#

local space is relative to an objects parent

#

global space is where the object is in relation to the world

#

for example, If i have an object whos global position is (100,100,100) and I set a child object to have a position of (200,200,200), then the child will be placed at (200,200,200) relative to the parent. i.e. having a global position of (300,300,300)

inland hemlock
#

If I'm understanding right, just calling .transform gets the local transform, while .global_transform gets the global?

solid whale
#

correct

inland hemlock
#

That did it, thanks!