- Home /
Rotating a child and a parent, simultaneously
I´m going crazy...
I have two rotation, which workd well independently, but together they have a really wierd behaviour.
The child is:
at.rotator.transform.localRotation = Quaternion.AngleAxis(curAngleZ, at.rotator.forward * -1) * start;
The parent is:
temporaryObjectForRotationOnYAxis.transform.localRotation = Quaternion.AngleAxis(temporaryObjectForRotationOnYAxis.transform.localEulerAngles.y + mouseDragX3, temporaryObjectForRotationOnYAxis.transform.up);
And it does not work. it, goes all crazy, with rapid and umpredictable behaviour. I even tried changing it to euler angles.. Still the same behaviour...
Any Ideas on how should I tackle this problem?
Thank you.
Answer by Bunny83 · Sep 16, 2016 at 10:51 PM
Local rotation is in local space. So using at.rotator.forward makes no sense as this gives you the forward axis in worldspace. You might want to use
at.rotator.transform.localRotation = Quaternion.AngleAxis(curAngleZ, -Vector3.forward) * start;
However it depends on your actual setup. Also
it does not ork
Is not a useful description of what happens or what would you expect.
You are right, does not work, it is not a proper description. But I find it difficult to say that it, goes all crazy, with rapid and umpredictable behaviour.
I am using at.rotator.forward because that is the direction of the axis in which I want to rotate. thank you for taking the time ;)
Why would you want to use a worldpace axis in a local rotation? That means the rotation axis as seem from local space will change when the parent rotates. Vector3.forward is the local forward axis. $$anonymous$$aybe you want to exchange your two rotations so start comes first.
at.rotator.transform.localRotation = start * Quaternion.AngleAxis(curAngleZ, -Vector3.forward);