The Universal Vehicle Combat kits feature an extensive camera system for your game, making it very easy to set up all kinds of camera views on your vehicles, and control exactly how the camera behaves in each camera view.
The camera system is a framework comprised of several key parts:
  • Vehicle Cameras - represents a vehicle-following camera in the scene.
  • Vehicle Camera Controllers - scripts that control how the camera behaves for a specific vehicle.
  • Camera Targets - something that a camera follows in the scene, such as a vehicle.
  • Camera Views - a way to represent a specific type of camera view.
  • Camera View Targets - transforms that represent the desired position and rotation of the camera in a specific camera view.

Vehicle Camera

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. 1.
    Add a new gameobject as a child of the vehicle.
  2. 2.
    Position and orient the gameobject where you want the camera to be in that view.
  3. 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.
Last modified 28d ago
Copy link