[Bug?] Relative rotation not working as expected

I am trying to rotate a mesh component relatively to the Root component (around the axes of the root) (or in general around any component the mesh is parented to), but the add relative rotation block ist not behaving as i had expected. Some screenshots:

This is my setup:

When pressing G the rotation works perfectly, even when tilted the mesh component does not rotate around the local z axis, but around the root z axis. But when pressing F the rotation occurs on the local axis.

From the starting position (axes aligned), after pressing G a couple of times:

59421-setup.png

Until here everything is going as epected, but pressing F now causes this:

The mesh has rotated not relatively to the root, but has performed a local rotation around its y axis. Pressing G another couple of times shows that the relative z axis rotation is working correctly:

59423-rotation+2.png

What am i doing wrong? Maybe i did not understand the function of the add relative rotation block (which is documented somewhat sparsely)? Maybe i did not understand the difference between the add relative rotation and add local rotation blocks? Is there another block that rotates around the axes of the parent component or do i have to use vector math?

Any advice is appreciated! Thanks

Hello Lazarus5000,

The node is functioning properly, as it is adding relative rotation, but never resetting the values, which is why you’re getting the rotation occurring based on the child’s rotation. For example, you’re rotating the child 2 degrees along the z axis, and then rotating it along the Y axis. However, this 2 degree rotation on the z-axis has not been reset, which is why your rotation is behaving as it is.
You are correct that the best way to accomplish what you are looking to do would be to use vector math. You’d have to store the parent’s initial rotation in a variable, and then add the rotation that you want each time. After you do this, set the relative rotation for the child with this new value and that should work.

Have a great day,

Sean Flint

Hi Flint,

thank you for the answer, but i am afraid i did not describe my problem precisely enough.

I am not trying to reach 2 different rotations depending on which key I press and setting a fixed rotation for each, therefore I do not want to reset the rotation I already perfomed on the child along the z axis, I want to keep the rotation as it is and then rotate around the parent’s y axis, and not the child’s y axis as it is happening now.

With the current setup the initial rotation around the z axis was just to be able to differentiate between a local rotation of the object around its own y axis and a relative rotation of the component around the parent’s y axis (not rotating around the z axis first would not make it possible to see if the component is rotating around the own local axes or relative to the parent’s axes)! What i was trying to illustrate is that a relative rotation around the z axis indeed rotates around the z axis of the parent, but a relative rotation around the y axis only rotates around the local y axis of the component, and not the y axis of the parent.

What else is the function of the AddRelativeRotation block, if not adding rotation relatively to the parent’s axes oposed to the AddLocalRotation block which applies local rotation around the local axes of the component?

Thanks again and i hope i made my point clear this time.
Lazarus5000

Hello Lazarus5000,

What you can try to do is instead of targeting two different components inside of one blueprint, create a child blueprint that uses the same rotation behavior as its parent, and then see if that gives you the results that you’re looking for. I look forward to hearing your results.

Have a great day,

Sean Flint

Anyways i managed to solve it now and i am marking your answer as accepted because of the effort and advice that helped me achieve it.

Thanks again.

You are using the wrong function mate. Instead of AddRelativeLocation you must use AddLocalRotation. They work a bit different. The rotation around the Z-axis is working, because there is no difference between the parents Z-axis and the childs Z-axis. AddRelativeRotation adds rotation taking in consideration the local rotation of the parent. It adds rotation relative to the local space of the parent. AddLocalRotation on the other hand adds rotation relative to the local space of the object being rotated.

AddRelativeLocation

AddLocalRotation

1 Like

Do it in this way. This video uses this logic. Unreal Engine 4 \ Head rotation No mistakes \ Поворот головы Без ошибок - YouTube