It's very straightforward to set up a camera to follow a vehicle in this kit. The five key components involved are:

  • Camera Entity

  • Camera Target

  • Camera View Target

  • Camera View

  • Camera Controller

Camera Entity

A camera entity represents a camera that follows some object in the scene.

To begin, add EITHER a CameraEntity component or a VehicleCamera component to the camera in your scene.

If you want to follow an object that is not a vehicle, use the CameraEntity component. If you want the camera to follow a vehicle, use the VehicleCamera component, which derives from CameraEntity with some additional features.

Camera Target

A camera target represents an object that the camera will follow, and stores information about camera views on it.

Add a CameraTarget component to the root transform of any object you wish to follow with the camera.

Camera View Targets

A camera view target represents where the camera should be positioned and rotated for a camera view, and provides individual settings for how the camera should behave in a specific camera view.

To create a new camera view on a vehicle:

  1. Add a new gameobject as a child of the vehicle.

  2. Position and orient the gameobject where you want the camera to be in that view.

  3. Add a Camera View Target component.

Camera Views

At this point you have a camera view target but no way to identify what view it is. The Camera View is a scriptable object that represents a type of camera view that may be found across different vehicles (e.g. cockpit view, chase view, etc).

To create a new Camera View, right click inside the Project tab of the Unity Editor and select Create > Camera View. Name it whatever you like.

Now drag this camera view into the 'Camera View' field of the Camera View Target you created in the previous section.

Camera Controller

A camera controller is responsible for managing the camera behavior.

To get started seting a camera controller up, add the VehicleCameraController component (if the camera is following a vehicle) or the CameraController component (if it is not following a vehicle) to the camera hierarchy.

All camera controllers derive from the CameraController base class. The VehicleCameraController (which inherits from Camera Controller) is provided to enable you to easily access a reference to the vehicle that is being followed, and specify (if you wish) which vehicle classes the script should run with.

You can add any number of different camera controllers to the camera hierarchy for different types of vehicles.