How to set 3D object's position when instanced?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By HashtagOrNah

I am trying to a get a spawn point system set up. I am trying to figure out how to use the Position3D node to set the position and then set the position of the player to the position of the Position3D node. I have no been able to figure out how to set the player’s position.

Thanks in advance,

:bust_in_silhouette: Reply From: kidscancode

You can set a Spatial’s position in space using transform.origin. If you want to use a Position3D’s transform to do it, get a reference to that node.

new_node.transform.origin = $Position3D.transform.origin

Note: these are in local coordinates, you may need global_transform depending on your node setup.

If you want to use the Position3D’s position and orientation:

new_node.transform = $Position3D.transform

Worked like a charm! And the global_transform was indeed what I was looking for, thanks for the help!

HashtagOrNah | 2020-01-06 16:36