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.

That's definitely not normal behaviour because I use both custom and standard transparent shaders without that problem. The only thing I can think of at the moment is that the render queue/render order is wrong. Are you using standard shaders for both the opaque and transparent meshes?

1 Answer

1

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.

OK interesting... Yes i use standard shaders for both. I actually just made a new project with a standard opaque object, a standard transparent object and a transparent worldspace UI image and everything works normally... How would I change the render queue or render order?