0 votes

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.

.

in Engine by (52 points)

1 Answer

+1 vote
Best answer

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
by (20,923 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.