0 votes

The title is self explanatory
I need to know how to rotate a spatial node attached to the player locally because I've been having this problem when the player look s the other way around the rotation shifts
For an example:
I want to rotate this node to the right of the player (90 degrees) when i press "move left" key it works fine but when i look the other direction and press the "move left" it goes to opposite way
Here's how the code looks like:

If Input.is_action_pressed("move_left"):
     pivot.rotation_degrees = lerp(pivot.rotation_degrees, 90, 0.1)
Godot version 3.5
in Engine by (57 points)

1 Answer

0 votes

I'm pretty sure I don't understand it. Maybe sending a screenshot of your scene would make this more clear. Or maybe a bit more of the code?

Generally if you rotate parent node, all child nodes will move with it to stay on the same place relative to parent. If you need to rotate just a child node, you run ChildNode.rotate() and it will rotate itself without modifying parent.

I'm making a wild guess here, that if you rotate parent, you rotate it not horizontally, but vertically, and they your child node (pivot?) it upside down and "rotate left" is still valid in its point of reference.
Imagine looking at spinning Earth and then looking at it upside-down. It still spins in same direction, but you see it differently.

by (204 points)
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.