Godot Version
4.2
Question
The child node seems to combine its rotation with it’s parent node causing it to always be at a slant. How do I fix this?
4.2
The child node seems to combine its rotation with it’s parent node causing it to always be at a slant. How do I fix this?
That is the correct behavior. Think of it this way. A child is inside of the parent (as weird as that sounds). So what ever happens to the parent also happens to the child.
Each node has a set of local and global parameters for position, rotation, and scale (local being parent space and global being world space). So if you want the child node to not rotate with the parent then you will have to set its global_rotation to the desired rotation every frame.
Yeah, as mentioned your child node inherits any transforms including rotation. I believe once you start running the game, any translations are relative to the orientation the shape is in when the game starts.
So if you rotate something 90 degrees in the scene tree. If you try to update the rotation in code, you can know that 0 degrees is the 90 degrees you already set the rotation to.
Depending on your use case, you could use a RemoteTransform
node (with Rotation
turned off), or maybe even toggle Top Level
on for your child node
It is also the child of a plain node.