Using a transform.Lookat to set a rotation for a Vector3.lerp.


I am trying to figure out how to store a rotation for the second parameter for a Lerp function.

Right now I am using a transform.Lookat to find the desired final rotation.

How ever its a void function and does not return a Quaternion, is there a different method to find this desired rotation?


LookAt doesn’t return a quaternion, but you can check the result in another way:

Quaternion myReturnValue = transform.rotation;

If you need to create an empty GameObject to perform this sort of operation, that’s fine. If it’s something you’ll be doing often, you can recycle that empty object as often as you need.

The real command is Quaternion.LookRotation. It takes a direction vector as input.

Transform.LookAt(pos) is really just a shortcut for transform.rotation=Quaternion.LookRotation(pos-transform.position); (and the docs also give an example. Pretty much the same one, but I already typed this.)