Don't understand Quaternion.MoveRotation, RotateTowards, LookRotation
What does Quaternion.MoveRotation, Quaternion.RotateTowards, and Quaternion.LookRotation do? From what I read on the Unity Manual, MoveRotation takes an argument and smoothly changes the objects rotation to that value. RotateTowards does the same thing but I can set where the rotation starts and where it should end, along with how many degrees the object rotates by each time it's called. As for LookRotation, it doesn't actually do anything to an object but returns some kind of value. Is my understanding correct, and can someone explain LookRotation in more detail? Also, what scenarios would I use .RotateTowards and not .MoveRotation since they kind of do the same thing?
Answer by xxmariofer · Sep 08, 2020 at 08:36 AM
not exactly you are confusing usecases and what it actually does.
Quaternion.RotateTowards
is similar to Vector3.MoveTowards, if you for example use RotationA is 0,0,0 degrees, target rotationB is 180,0,0, and the step is 1 degree, it will return 1,0,0 just adds "a step" towards the rotation
RigidBody.MoveRotation
the main difference are that you rotate with the rigidbody, so you rotate using physics, there is "no target" rotation, you only tell the object the rotation in which you rotate and you add forces in that direction
Quaternion.LookRotation
this is simplier with an example, imagine you want your objectA to look to objectB, you would use LookRotation, that emthod returns the quaternion of an object "looking" to a second object
@xxmariofer Thanks for the explanation, but just for clarity
So, LookRotation takes arguments telling which direction you want it to look toward, and which direction is up, and returns the rotation necessary to get to that direction, or does it return the rotation of the object that would have those directions?
And RotateTowards adds the step argument to the from argument when it is called, and the target distance is just the stopper?
Also, does $$anonymous$$oveRotation add the argument rotation to the current rotation of the object to get a new rotation, or does it rotate the object to the rotation. (if the argument passed is 100,0,0, would 100 be added to the objects x rotation, or would the object rotate to 100,0,0)?
returns the rotation of the object that would have those directions. it is basically yes, the target is the "stopper" as it name says is the target rotation, maybe with $$anonymous$$oveTowards that is basically the same you find it easier, if you have the gameobject at a positionA and you want to get it to positionB, calling $$anonymous$$oveTowards (the same rotate towards with directions) will add a step from A to B. the object rotates to 100,0,0 but interpolated with the physics system