This seems like a simple question but I couldn't get it to work. I want to rotate a game object using a quaternion, relative to world space.
I have tried this:
But it still seems to rotate in the object's local space.
asked Mar 23 '11 at 07:59 PM
Assigning a quaternion of (0, 0, 0, 0) may have unpredictable results. Without checking I can't tell you exactly how Unity will handle this, but if the intent is to reset the orientation to identity, assign Quaternion.identity instead.
Also, make sure xrot, yrot, zrot, and wrot are actually intended to be used as the elements of a rotation quaternion. (I'm assuming they are based on the use of the 'w' element, but it's probably worth checking nonetheless.)
Finally, I'm not sure what the behavior of Rotate() is when the object is a child object and the rotation is specified in world space. If Rotate() doesn't handle this case correctly though, you can apply the rotation directly by modifying transform.localRotation (with a little quaternion math, you can achieve the effect of the rotation being applied in world space).
Sorry if my answer is a little vague, but I'd have to check some things in order to be certain of the above answers.
answered Mar 23 '11 at 10:20 PM