[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:
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:
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
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.
Do it in this way. This video uses this logic. https://www.youtube.com/watch?v=Mlkw83N9z60&feature=youtu.be![alt text]
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,
answered Sep 28 '15 at 07:45 PM
Sean L ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here