Cinemachine comes with a number of demo scenes to help you get started. Here we explain them and show some more advanced configuration ideas.
Here’s a video which gives an overview of Cinemachine Base Rig
Working with Cinema Director
You need to be on Cinema Director version 184.108.40.206 or higher for it to allow Cinemachine virtual cameras in the shot tracks
Cinema Director is a fantastic timeline editor plug-in for Unity. We used it on all the cutscenes for Homeworld: Deserts of Kharak
There’s a few things you need to do at the start to make them work perfectly together.
The Cinema Director ‘shot’ will point to a Cinemachine Virtual camera. As a default, Cinemachine has a 2 second blend to each new camera which is turned on. This will cause your ‘cuts’ to do a blend instead of a cut, which is probably not what you want. It’s an easy fix and you have a couple of options on how to fix it.
1. Select the AUTOGEN_CinemachineRuntime component
2. Create a Blend Settings asset if you don’t have one already
3. Set the Default Blend to be a cut (see below)
By default, Cinemachine does a 2 second SLERP blend between any new camera which is turned on. This will cause your Cinema Director cuts to actually blend over 2 seconds when triggering a new camera.
Select the default blend in the AUTOGEN_CinemachineRuntime
It will open up the curve editor which is by default a smooth blend over 2 seconds.
3. Right click on the key and select delete key. This will cause the curve editor to have just one key, which tells Cinemachine that it’s a cut
Now you’ve setup the default Cinemachine blend to be zero seconds – a cut – and all Cinema Director shot changes will be hard cuts. Every time you call a new Cinemachine camera it will cut. However, if you want two cameras to blend, you can specify how any camera blends to any other camera with the Blend Settings panel.
Of course, if you want them to be blends, you can leave the default in there, or specify explicit blends between cameras and keep the default cuts. You can also keep the default blend as a blend (for gameplay state-machine reasons) and then specify in the Blend Settings that the cutscene camera A to camera B (camera C, etc. etc.) shots to be cuts with specific definitions in the custom blend stack – see above. It’s a bit of data, but it gives you the most control !
The basic Cinemachine setup is for the camera body – Transposer – to be attached to something and for the camera to look at – with the Composer – some other object. Don’t set the Composer and Transposer targets to be the same object as the camera body and orientation will move the same, cancelling out any desired lag.
For Cinematics: Put the camera body where you want it or animate the movement and set the Composer to track the subject. Dial up the compositional controls on the Composer to get the shot how you like it. That camera will now always figure out that composition, no matter what the subject does.
Inheriting PostFX or using custom ones per shot
Cinemachine allows for custom postFX to be used per shot, or globally or in any combination.
Typically for a global PostFX setup, you put them on the actual Unity camera – as opposed to the Cinemachine virtual camera – which is probably in the root of the scene:
PostFX do not live on Cinemachine virtual cameras, however if you want any particular Cinemachine camera to have different postFX, or tweaks to the main camera’s postFX, then all you have to do it put either a copy of the main camera (or a new Unity camera, not Cinemachine camera) under the Cinemachine virtual camera. Below CM_B_PostFX is an actual Unity camera with postFX settings on it. Cinemachine will inherit those settings for the duration of that shot.
Another way of saying how it works: Cinemachine will use the MainCamera postFX unless there’s a child Unity Camera under any given Cinemachine camera.
Blending Composers to move subject around the screen
A single Cinemachine camera doesn’t necessarily mean a single shot. Wonderfully sophisticated shots can be the product of blending multiple Cinemachine cameras together over time.
Imagine a shot where the subject wants to start out on the left side of the screen and end up on the right side of the screen. You can do this very simply by blending two Cinemachine shots together over time, the first one with the Composer set with a left composition and the second camera with the composer set to a right composition.
Because blending cameras together is so straightforward, it’s easy to create sequences and camera moves with incredible levels of sophistication and precision. Simply duplicate the current camera and put some tweaks into it: Position, FOV, noise, composition – anything!- and then blend to that camera when and over how long you want.
Every camera parameter blends through the Cinemachine Blender, so you can have just one tiny aspect change or as many as you want. Increase the camera shake after a game event, or slightly push the FOV in when your character goes through a trigger volume – anything is possible.
We have built sequences which were ‘one shot’ but blended through 10 or more cameras. Yes it does end up being a fair number of assets/data, but it’s all tuneable real-time and you’ve always got ultimate control.
Marionette systems to drive Cinemachine
Currently Cinemachine’s Composer only tracks one object but that doesn’t mean you can’t use Cinemachine to compose multiple targets.
An interesting way to drive Cinemachine is through the use of a ‘Marionette’ system where simple scripts are used to drive target objects which Cinemachine tracks.
Scenario:. Say your game mostly targets one hero object but when multiple objects come onto the screen, it wants to target all of them. Here’s a basic setup which will explain the Marionette concept.
1. Have your main game camera target the hero object. Put that as the Cinemachine Composer target.
2. Create a new camera for when multiple objects come on screen
3. Create a dummy object and call it ‘multiple target average’ or something like that
4. Write a simple script to move this object to the average position of all the multiple objects you want to target
5. Set the new ‘multiple object’ camera’s Cinemachine Composer to be on this new dummy object which moves to the average position of all the new objects
6. Blend to this new camera when all the new objects come on screen
Cinemachine will go from tracking your hero to smoothly tracking the average position of all the new objects on screen.
Because the Cinemachine Composer has versatile dampening controls, the movement of your dummy average position object doesn’t really have to be that smooth, just put a little dampening into the composer and you’ll get nice camera weight.
State machine setups using Blend Settings
Sophisticated camera state machine setups are easy to create in Cinemachine.
These types of camera setups are great for 3rd person AA style games, or cinematic style camera games like the Resident Evil or God of War series. The basis for this type of setup is the idea that you have a bunch of different cameras which blend and cut together based on gameplay variables like player position in the world or animations, etc.
The AUTOGEN_CinemachineRuntime contains all the blend settings between cameras. You can set exactly how you’d like to blend or cut between any camera – and it even supports wildcards so ANY camera blending to a particular camera can have a custom blend.
Below is a setup for a state machine camera system which is driven from the game states. Custom cameras are created to best shoot ‘Combat_major’ vs ‘Combat_minor’ or ‘Explore’ type scenarios. It’s easy to setup large dynamic camera systems which do exactly what you want, all without having to do any programming or bug one!
Tuning up some convincing Noise
The Noise module is a multi-layered Perlin noise function which is applied after the Composer and adds additional transforms. It has controls for Position and Orientation. You can add as many layers as you want by increasing the Size value.
Procedural noise is a complex thing to make look real. Convincing hand-held motion is a mixture of low, medium and high frequency wobbles which together combine to create something believable.
Position / Orientation Size This is how many noise functions you’d like to blend together for the Position or Orientation or both. Mix at least 3 Orientation channels together for some realistic hand-held motion.
Amplitude defines the amount of noise in degrees. Wider lenses will need larger degree values in order to ‘see’ the shake. Telephoto lenses use smaller values as that small setting appears amplified through narrower FOV lenses.
Frequency defines the speed of the noise in Hz. Typically a ‘low’ frequency value might be around 0.1. Consider that your game is running at 30 or 60hz, so settings higher than that will be ‘on the other side’ of the Nyquest frequency, meaning that they will not be directly tracked. A setting of 100 will be higher than what the camera can track as your game is only running at say 60hz. It can look kind of choppy since the camera can’t track something which is sampling faster than what the game is running at. It can also look kind of cool, but rarely. Experiment. Typically, for most hand-held setups, the low is around 0.1-0.5, the mid maybe .8-1.5 and the high around 3-4. That’s 3-4 shakes back and forth per second.
The most convincing camera shakes are typically done with Orientation noise as that’s where the camera is aiming. Handheld camera operators tend shake more rotationally than they do positionally, but of course feel free to mix in some Position noise, just remember it’s probably best to start with the Orientation.
We’ve included a number of presets to get you going, under Assets/Cinemachine/Noise and of course you can add as many of your own as you wish, just right click in the Asset window Create->Cinemachine->Noise, and drag that asset into the Noise Settings window under that VirtualCamera.
You can also animate the Noise through the Noise Amplitude Scalar, and Noise Speed Scalar to ramp the effect up and down based on other ideas, such as nearby explosions or vehicle speed or any other game output. Super versatile !