I found the LookAt() function but it “jerks” the camera into position. Is there a simple way to have the camera smoothly look from one object to another or does someone have a script they can share that does this?
Here’s a question about it now. How do I find the end-rotation in order to “look at” the object I want to? I have the LookAt() function but don’t see a way to just retrieve the look at angle without actually looking.
I may have spoken too soon. There is no Quanterion.LookAt() function in Unity.
So, here’s my question, how do I get the Quanterion for the current rotation and also the Quanterion for the rotation I want to use as the target?
I have the camera to start with and I know the position of the item I want it to pan to look at. Can someone help me with the code needed to pan from the current state to the state desired?
var camCurPos : Vector3 = camera.transform.position;
var camCurRot : Quanterion = camera.transform.rotation;
var camTargetPos : Vector3 = targetobject.transform.position;
var camTargetRot : Quanterion = targetobject.transform.rotation;
What do I need to write code wise given the above data to arrive at the camera rotation needed on the next frame and pan towards the target over time?
Well, I cheated and added a spotlight to my scene and put it exactly where the camera is but turned its Intensity to 0. I have it call LookAt() to get the target rotation and then call the Quanterion.Slerp() to slowly transition the camera from its current rotation to the one the spotlight is pointing at.
It works but I would like to know how to get the LookAt() rotation without having to use this hack. Does anyone have the math to calculate the LookAt() value without actually having to perform the LookAt() function?