Basically I have a room with the camera starting in one of the top corners looking across the room. I want to smoothly pan the camera to look at a particular object within the room. Two ideas come to mind: Hardcode the camera motion through tranform.Translate and transform.Rotate. The other idea is to preset an empty game object in the position and rotation of where I want the camera to be and then have the camera gradually adopt the empty game object’s position and rotation.
The first solution would be a last resort for me. The second one sounds like it could work but I have no idea how I would get that smoothing effect (in particular, having the X, Y, Z positions and rotations get reached by the camera at the same time so that I don’t have a “jolting” effect when one axis reaches its designation while the others still haven’t).
Any solutions or alternative ideas would be much appreciated.
You could try to Lerp and Slerp the camera. One will smoothly move the position to a certain Vector3 and one will smoothly rotate to a Vector3 I think. I’ve never handled camera movement like that but I can try it and update on here with some code if you want.
Lerp and Slerp did the trick ^^
Just out of curiosity, how would you get Slerp to arc in a sphere, say horizontally or even diagonally rather than vertically?
I have three thoughts firstly why not just use the Unity build in animation tool? Put it on the camera then call it on awake?
Secondly iTween as the above said. Thirdly in the standard assets there is a script in the platformer tutorial, the one with Lopez (i think his name is) where there is a script attached to the camera that glides toward the target player from where ever you place it on the scene.
Thanks for the reply. iTween looks like it could be really useful but I need a button click to initiate the panning effect of the camera so calling it on awake or permanently attaching the camera to the player isn’t an option.