I am trying to rotate a game object 90 degrees about the global axis but can only seem to make it rotate about it’s local axis.

I am calculating rotation like this and then slerping it after:

``````if (direction == directions.right)
{
newRotation = transform.rotation * Quaternion.Euler(0,-90,0);
}
else if (direction == directions.left)
{
newRotation = transform.rotation * Quaternion.Euler(0, 90, 0);
}
else if (direction == directions.up)
{
newRotation = transform.rotation * Quaternion.Euler(90, 0, 0);
}
else if (direction == directions.down)
{
newRotation = transform.rotation * Quaternion.Euler(-90, 0, 0);
}
``````

Cheers!

To rotation about the global axis, reverse the order the Quaternions are combined:

``````if (direction == directions.right)
{
newRotation = Quaternion.Euler(0,-90,0) * transform.rotation;
}
else if (direction == directions.left)
{
newRotation = Quaternion.Euler(0, 90, 0) * transform.rotation;
}
else if (direction == directions.up)
{
newRotation = Quaternion.Euler(90, 0, 0) * transform.rotation;
}
else if (direction == directions.down)
{
newRotation = Quaternion.Euler(-90, 0, 0) * transform.rotation;
}
``````