Camera Pan using Look at
How to make the camera follow an animated empty gameobject
--
In this article we will use another way to pan the virtual camera. We will use the ‘Look at’ property of our virtual camera to look at an empty game object. Then we will animate the empty game object.
Create Empty GameObject for the Virtual Camera to follow
1 Create Empty GameObject
1.1 Drag the object into the Actors in Hierarchy
1.2 Drag the object into the Look at property of the virtual camera
Look at Empty GameObject and the Dead Zone
2.1 Select virtual camera with the filled look at
2.2 Lock the Inspector
2.3 Select empty game object and move it around
The yellow square is the target that the camera follows. If it hits the edges of the dead zone the camera starts moving. The dead zone can be adjust from the Inspector of the virtual camera under Aim.
Animate the Virtual Camera Look At Target
We are going to animate an object so we need another animation track.
3.1 Timeline (panel) > Add > Animation Track > Drag the camera target into the box > Create Animator Component
3.2 Hit the record button on the animation track to start recording
Here it may be convenient to select the virtual camera again and lock the inspector so you can see the deadzone.
Less Robot Camera
Currently the camera movement is very mechanical.
Let’s add some damping for when our camera follow target leaves the deadzone.
Virtual Camera > Inspector > Aim > Horizontal and Vertical Damping
(Another way to smooth things out you can adjust the animation curves)