Add procedural behavior to a Cinemachine Camera
Set up a Cinemachine Camera with procedural behaviors:
- Add behaviors to control the camera position and rotation,
- Specify a GameObject to track for automatic follow and aim,
- Add default noise to simulate real-world physical camera shaking, and
- See how to an Extension to get advanced camera behaviors.
Note
This task requires some preparation:
- You must have created at least one passive Cinemachine Camera, and
- Your Scene must already include a GameObject you can target to follow it with the Cinemachine Camera.
Add Position Control and Rotation Control behaviors
In the Hierarchy, select the Cinemachine Camera GameObject.
In the Inspector, in the Cinemachine Camera component, set the Position Control property to Follow.
Unity adds a Cinemachine Follow component to the GameObject.
Still in the Cinemachine Camera component, set the Rotation Control property to Rotation Composer.
Unity adds a Cinemachine Rotation Composer component to the GameObject.
Note
You get the same result when you create a Follow Camera directly from the Editor's menu: GameObject > Cinemachine > Targeted Cameras > Follow Camera. The goal here is to show how to add behavior to an existing Cinemachine Camera.
See the Cinemachine Camera component reference to get the list of available Position Control and Rotation Control behaviors and access their detailed descriptions.
Warning
A Cinemachine Camera GameObject can only have one Position Control behavior and one Rotation Control behavior selected at a time. If you edit the properties of a behavior component and then select another behavior from the Cinemachine Camera component, your edits are lost.
Specify a GameObject to track
The behaviors selected in the previous step require a tracking target. To meet this requirement:
In the Inspector, in the Cinemachine Camera component, set the Tracking Target property to specify the GameObject to track.
Move the targeted GameObject in the Scene to test the Cinemachine Camera behaviors.
The Cinemachine Camera automatically positions the Cinemachine Camera relative to this GameObject at all times according to the Follow behavior, and rotates the camera to look at the GameObject according to the Rotation Composer behavior.
Add noise for camera shaking
To optionally add noise to simulate real-world physical camera shaking:
In the Inspector, in the Cinemachine Camera component, set the Noise property to Basic Multi Channel Perlin.
Unity adds a Cinemachine Basic Multi Channel Perlin component to the GameObject.
In the Cinemachine Basic Multi Channel Perlin component, click on the configuration button at the right of Noise Profile.
Under Presets, select an existing Noise Settings asset.
Enter Play mode to see the effect of the selected noise profile on the camera, then exit Play mode.
Warning
If you edit the properties of the Cinemachine Basic Multi Channel Perlin component and then change the Noise selection from the Cinemachine Camera component, your edits are lost.
For further noise behavior adjustments, see the Cinemachine Basic Multi Channel Perlin component reference and Noise Settings asset reference.
Add a Cinemachine Camera Extension
To optionally add an Extension to the Cinemachine Camera when you need to get a specific or advanced behavior:
In the Inspector, in the Cinemachine Camera component, click on (select) at the right of Add Extension.
Select an Extension in the list.
Unity adds the corresponding Extension component to the GameObject.
Note
You can add as many Extensions as needed to the same Cinemachine Camera GameObject. You can remove an Extension as any other GameObject component.
See the Reference to get the list of all available Cinemachine Camera Extensions and access their detailed descriptions.
Next steps
Here are potential tasks you might want to do now: