Using Cinemachine

Cinemachine is Unity’s powerful camera system that simplifies creating dynamic and cinematic camera behavior without requiring complex scripting. It provides tools for easy camera control, targeting, and transitions in your Unity projects. The Cinemachine asset package that provides tools for creating intelligent cameras to frame different elements of a scene.

Setting up Cinemachine

To import Cinemachine, go to the Package Manager in Unity, find it in the Unity registry, and install it.

Once installed, you can start using Cinemachine to create dynamic camera movements, such as following a character around the scene.

You start by creating a virtual camera from the Cinemachine menu, which will be used to follow the player character. Click on CINEMACHINE > VIRTUAL CAMERA

When adding a cinemachine object you will see the main camera changes to a cinemachine brain by default, as a reference for all new cameras

Cinemachine cameras provide a wide range of options and features, from aiming, to following, tracking and other behaviours.

Follow Player

The camera needs to be set to follow and look at the player character by dragging the player object into the "Follow" and "Look At" fields in the Cinemachine virtual camera properties.

Any camera in the scene can match you scene view, you can do this by selecting the camera and going to EDIT > ALIGN WITH VIEW

Fine-tune the camera's position and movement using the "Follow Offset" and "Damping" settings to ensure smooth and dynamic tracking of the player character.

Free look camera

Depending on your game and gameplay, you may need different camera movement and behaviours. Cinemachine options can be customised to setup a camera the way you need it for gameplay

An orbital camera can be made and set to follow and look at a specific object, such as a building, and adjust the orbits to control the camera's movement around the target. To make this you will need a FREE LOOK camera

Choose a good object in the scene for the camera to focused on, and again assign that object in "Follow" and "Look At"

The camera will love and focus on the selected object. Free Look cameras come with orbit rigs, allowing you to define the bottom, mid and top orbit limits. Modify the radius and height of the camera's orbits to achieve the desired view and how to use the mouse to control the camera's elevation and horizontal motion.

Creating a dolly track

Another option is to create a camera that follows a defined path, such as a fly through or movement for a cinematic. A Dolly track with a cart can guide a camera along a specified path.

This create 2 objects: A track and a Cart

Adjust the position, rotation and direction of the track to suit your needs. The camera will start at from waypoint 0. You can also add waypoints via the component on the track object

Set up and adjust the path by adding and tweaking waypoints to control the camera's movement and elevation. Once happy with your track, check the cart settings. The cart will run along the track via position. The distance settings of which can be changed via Position Units. Distance uses meteres, and normalize using 0-1 (0 being start and 1 being end)

Drag your main camera onto the cart to make it a child - thus making it inherit the carts position. Make sure you reset any position and rotation values for the camera (X,Y,Z).

Animate the Dolly cart via the animation tab (create a clip etc) without using any code. Adjust the speed and timing as desired.

Last updated