Relocate a node to a global coordinate contained in a Vector3

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By dodgyville
:warning: Old Version Published before Godot 3 was released.

I’m generating spawn points in a volume in a Scene. I’m storing the coords in a Vector3.

How do I relocate a node to that global position? I think it’s something like:

 var spawn_point = Vector3(-11, 0, 4)
 var clone = character.duplicate()  
 clone.translate(spawn_point - character.get_global_transform().origin)

The character I’m cloning is scaled and transformed in the scene already.

does clone.transform.origin = spawn_point not work?

volzhs | 2018-01-18 08:02

Thank you! That put me on the right track

dodgyville | 2018-01-18 22:47

:bust_in_silhouette: Reply From: Zylann

Not sure why you duplicate it, but you can set its translation:

clone.translation = spawn_point

If your spawn point is in world space but clone is not in world space (for example, if it has a parent that is not at the origin), you can do this:

clone.global_transform.origin = spawn_point

Thanks, working. Part of the problem was that both my original object and the spawn area had parents that were rotated and that was throwing out the transforms.

dodgyville | 2018-01-18 22:49