0 votes


I wanto to perform an action if the child of PathFollow change it's rotation in the y axis. I've tried to use statements under globaltransform.origin and globaltransform.basis without success.

Thank you in advance.

in Engine by (91 points)
edited by

1 Answer

+1 vote
Best answer

I didn't try out PathFollow but I can tell you how to get the global y-angle for any spatial.

Also, I did some tutorial/text about 3D vector / transform operations:

You should get an angle with this code:

This gets the x and z components of the current direction vector of the global transforms z-axis.

So this basically is the 2D direction vector in the global X/Z plane.
(This will not work if the child is directly looking 90° up/down because the z-vector will then be looking up/down and therefore have a length() of 0 in the global X/Z plane.)

Then the angle to the global "forward" vector is calculated. This could as well be Vector2(0,1) if in your world +z is "forward". If you need degrees then you can use rad2deg.

by (3,358 points)
selected by

Thank you very much.

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 Frequently asked questions and 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 [email protected] with your username.