Welcome to Cinemachine

Cinemachine

Welcome to Cinemachine

Cinemachine is a suite of ‘smart’ procedural camera modules which allow you to define the shot and they’ll dynamically follow your direction.

Set up shots which track and compose motion in realtime, like AI camera operators. The procedural nature makes them bug-resistant as they always work to make the shot based on your direction. That’s great for gameplay, but they’re also amazingly fast for cutscenes. Change an animation, a vehicle speed, ground terrain - whatever - and Cinemachine will dynamically make the shot. You can use really telephoto lenses and not have to update the cutscene if things change.

The Brain

The idea is to tell the Unity camera where to go and what to do in response to gameplay and scene evolution. To do this, the first step is to give the Unity Camera a CinemachineBrain behaviour. Think of that as the movie director, who chooses among the available camera shots for the one that tells the best story at any given moment.

The next step is to populate your scene with intelligent CinemachineVirtualCamera objects. These can be thought of as skilled cameramen who are given instructions about what game objects to target, and how to follow them. It is the brain's job to monitor these and choose the most appropriate one to track at any given frame.

Virtual Cameras

A virtual camera is not a camera. Instead, it can be thought of as a camera controller, not unlike a cameraman. It can drive the Unity Camera and control its position, orientation, lens settings, and PostProcessing effects. Each Virtual Camera owns its own Cinemachine Component Pipeline, through which you provide the instructions for dynamically tracking specific game objects.

A virtual camera is very lightweight, and does no rendering of its own. It merely tracks interesting GameObjects, and positions itself accordingly. A typical game can have dozens of virtual cameras, each set up to follow a particular character or capture a particular event.

A Virtual Camera can be in any of three states:

  • Live: The virtual camera is actively controlling the Unity Camera. The virtual camera is tracking its targets and being updated every frame.
  • Standby: The virtual camera is tracking its targets and being updated every frame, but no Unity Camera is actively being controlled by it. This is the state of a virtual camera that is enabled in the scene but perhaps at a lower priority than the Live virtual camera.
  • Disabled: The virtual camera is present but disabled in the scene. It is not actively tracking its targets and so consumes no processing power. However, the virtual camera can be made live from the Timeline.

The Unity Camera can be driven by any virtual camera in the scene. The game logic can choose the virtual camera to make live by manipulating the virtual cameras' enabled flags and their priorities, based on game logic.

In order to be driven by a virtual camera, the Unity Camera must have a CinemachineBrain behaviour, which will select the most eligible virtual camera based on its priority or on other criteria, and will manage blending.

Blending

Camera Blending is a concept that brings the Virtual Cameras beyond the analogy of a cameraman. It is essentially an interpolation over time of one virtual camera position and state to another. If you think of virtual cameras as cameramen, then blending is a little like one cameraman smoothly passing the camera to another cameraman. You can specify the time over which to blend, as well as the blend curve shape. Note that a camera cut is just a zero-time blend.

The CinemachineBrain behaviour holds the instructions for blending. There you can specify the default blend (how virtual cameras transtion from one being live to another), and also specific overrides to the default blend in the form of an instruction list: "when this vcam goes live, blend like this", or "when bending from this vcam to that one, do it like that", and so on.

Getting Started

The first thing to look at is the CinemachineVirtualCamera behaviour. That should lead you to the pipeline of ICinemachineComponents which serve as instructions for controlling the Position, Orientation, and Lens of the camera. Create some Virtual Cameras in your scene, set their targets, and play with their settings to see what they do. Also have a look at some of the example scenes included with the package.

The API generally reflects what you see in the inspector for the behaviours of the different sorts of Virtual Cameras and their components. Have a look at the corresponding classes, beginning with:

  • CinemachineVirtualCamera
  • CinemachineBrain
  • CinemachineClearShot
  • CinemachineFreeLook
  • CinemachineCollider
  • CinemachineTransposer
  • CinemachineComposer

See Also

Other Resources