transform.Rotate(Vector3 axis, float angle, Space relativeTo)
by hand to understand what the difference between calling this function with Space.Self and Space.World is. I understand what’s going on conceptually, but I’m finding coding the behavior of calling this function with Space.World near impossible.
To be clear, what I’m asking for is low level implementation details. Quaternion/Matrix math in OpenGL/DirectX to accomplish what Unity does for us behind the scenes to accomplish this.
The difference is simple, when it’s Self the transform is going to rotate angle degrees on it’s specified axis. Which can be at any angle itself. However when it’s set to World then it doesn’t matter what the rotation of the transform itself is, it’s gonna rotate as if it was Quaternion.identity. Look at the pictures below, first one shows what the transform looks like when it’s in local space. You can see a button on the left of transform, rotate etc. tools. The second one is when it’s set relative to world space. Again, the buttons on the top left of tools.
Hope this helps clear things out, if not you should change the setting between local and global in the editor, and play around with rotation to get the difference between them.
Its a shortcut for using Quaternion.AngleAxis. You have to know Quaternions to really understand, and once you know Quaternions, it’s obvious.
Roughly, transform.Rotate(v, amt); works out to transform.rotation=Quaternion.AngleAxis(v,amt)*transform.rotation;. For local vs. world, flip it (one of those things where you have to know Quaternions.)
You can use transform.Rotate to rotate your object like this, Apply transform.Rotate in Update :
function Update()
{
// Slowly rotate the object around its X , Y & Z axis at 1 degree/second.
transform.Rotate(Time.deltaTime, Time.deltaTime, Time.deltaTime);
}