Ignore parent's rotation while rotating child node (3.0)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By thewraithmod
:warning: Old Version Published before Godot 3 was released.

I have a KinematicBody2D as the root node for my “Player” scene.

As a child of that node I have a Sprite node that I named “Weapon”.

I need to have the weapon sprite always point to where the mouse position is but because it inherits that root node’s rotation there is no way to make it face to the proper angle.

Even when I set the global rotation it will constantly snap back and forth to completely different rotations.

Is there any way to make it so a child node ignores its parent’s rotation?

:bust_in_silhouette: Reply From: Michael Paul

It’s by design that a child inherits its parent’s position, rotation, etc. That way a gun (child) can be pointed independently, but it will also change its direction if the player (parent) turns. The alternative would be to make them siblings in a parent container, where they could both work independently, but would both move/rotate with the container.

Regarding your specific problem with the “snap back and forth” when changing the rotation of your gun, you may be using degrees when your statement is expecting radians. Are you using set_global_rotdor set_global_rot?

Also, make sure you aren’t confusing rotate (changes the rotation relative to the current rotation) with set_rot / set_rotd (sets the global rotation).