Can I prevent a child node from inheriting X and Z rotation? How?

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

I have a spatial node that parents both a test cube and a camera for a third-person character. Currently I have a script controlling all of my motion on the spatial node, including rotation. However, I do not want the test cube to copy any of the rotation except for the Y axis rotation, so that it stays “flat” on the X-Z plane even when I look up and down. As it stands I’m trying not to make scripts for objects that I don’t think really need them; is there a way I can simply disable some of its inheritance properties through a menu? This is what I have at the moment if you need to see the tree:

Currently I just don’t allow changes in pitch angle, and as you can see, I need to use the spatial as a pivot point for the camera, which is a bit behind the cube and spatial. Ideally I want to accomplish this all within one script instead of having some motion in one script and some motion in another.

:bust_in_silhouette: Reply From: avencherus

As far as I know, at the moment there are no options in the editor for that. If you don’t want the automatic behavior, you have to intervene with script to specify your own.

So making a node not parented, and then copying the transform information you want when transformations occur. Or inside the child, getting the parent transformation matrix, picking the bits you want to cancel and divide them back out.

I just made one node that controls the Y rotation, with a child node that I rotate on the X. I only had to attach a script to the parent, then use get_node and tell the child to rotate on the X. Works kinda like a tankhead I guess.

HB | 2017-07-11 15:29

I’ve done something similar in the past with splitting the rotations into child nodes, in order to create a special camera rig with an orbit and X and Y rotations to be manipulated separately using slider controls.

That is definitely a creative approach to the Euler transforms if you’re not using quaternions.

avencherus | 2017-07-11 15:35