Question by
jespercal · Sep 20, 2017 at 11:37 PM ·
vector3quaternion
Change rotation of object around world's axis?
I'm trying to rotate an object around an axis, but it seems that the axis it rotates around is local. I would like it to rotate around the world axis, so no matter what angle the object is at, if I say that it should rotate to the right, then it's my right, even if the object is upside-down.
Comment
Best Answer
Answer by jespercal · Sep 21, 2017 at 12:07 PM
Well, I found the solution:
Vector3 vec = objectToRotate.transform.InverseTransformDirection(-Vector3.up); // Rotate around x axis.
float amountToRotate = 1;
objectToRotate.transform.rotation *= Quaternion.AngleAxis(amountToRotate,vec); // No matter how the object is angled, it'll always rotate around the x axis.
Your answer

Follow this Question
Related Questions
Slerp ignoring time component? 1 Answer
Look rotation viewing vector is zero 1 Answer
Clamp vector values to a minimum circular radius around player? 1 Answer
iron sight using inverse kinematic 0 Answers
Lerping Quaternion Eulers. 1 Answer