How to get a 3D position (translation) of a child relative to the root node

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

I expected

Vector3(weilder.translation.y,weilder.translation.y+1.925,weilder.translation.z)
to_global(weilder.get_node("Head").translation)

to output the same thing because they should be but it is always slightly off. Maybe I am misunderstanding

to_global()

I need it to be global because the gun is a child of the head which is a child of the player, who exists on the root node, but since the player sends a signal with itself as the parameter (wielder), I should be able to get the position of the wielder so the gun can shoot from the welder’s head position.

.

:bust_in_silhouette: Reply From: kidscancode

2 problems:

  1. You’re using (translation.y, translation.y+1.925, translation.z), so you’ve lost the x-axis.

  2. It’s much easier to get a Spatial’s global position using

global_transform.origin