Time for action – controlling the camera
We will only need one, fairly short script to control and manage our camera:
- To start and to keep everything organized, create a new empty GameObject and name it
CameraRig
. Also, to keep it simple, set its position to zero on each axis. - Next, create three more empty GameObject and name them
LeftPoint
,RightPoint
, andTopPoint
. Set their X axis positions to5
. Position theLeftPoint
to be in front of the slingshot and at3
on the Y axis. TheRightPoint
needs to be positioned in front of thepig
structure you created. TheTopPoint
can be over the slingshot, but needs to set to8
on the Y axis. These three points will define the limits of where our camera can move when being dragged and following birds. - Make all three points, and the
Main Camera
object, children of theCameraRig
object. - Now, we create the
CameraControl
script. This script will control all of the movement and interaction with the camera. - Our variables for this script start with a reference...