Cinemachine State-Driven Camera
The Cinemachine State-Driven Camera component activates a child Virtual Camera when an animation target changes states. For example, consider your avatar’s local-motion system and orbit camera. Your game feels more alive to the player when the camera shakes more as your avatar runs. When the avatar walks, blend for example to a Virtual Camera with more damping.
The animation target for a State-Driven Camera is a GameObject with an Animator component controlled by an Animator Controller.
Assign normal Look At and Follow targets to each child Virtual Camera. If a child Virtual Camera has no Look At or Follow target, State-Driven camera uses its own, respective targets.
State-Driven Camera has a list that assigns child Virtual Cameras to animation states. You can define default and custom blends between the State-Driven children.
In the Inspector, the State-Driven camera lists its Virtual Camera children. Use this list to add and delete child Virtual Cameras, and assign priorities.
To create a State-Driven camera:
Set up the animation target GameObject to control it with an Animator Controller.
In the Unity menu, choose Cinemachine > Create State-Driven Camera.
A new State-Driven camera appears in the hierarchy with a new child Virtual Camera.In the Inspector, assign the animation target you created in step 1 to the Animated Target property.
If needed, add more child VIrtual Cameras either by clicking + in Virtual Camera Children or dragging and dropping existing Virtual Cameras in the Hierarchy window.
Use the State to assign child Virtual Cameras to the animation states.
Properties:
Property: | Function: |
---|---|
Solo | Toggles whether or not the Virtual Camera is temporarily live. Use this property to get immediate visual feedback in the Game view to adjust the Virtual Camera. |
Game Window Guides | Toggles the visibility of compositional guides in the Game view. These guides are available when Look At specifies a GameObject and the Aim section uses Composer or Group Composer, or when Follow specifies a target and the Body section uses Framing Composer. This property applies to all Virtual Cameras. |
Save During Play | Check to apply the changes while in Play mode. Use this feature to fine-tune a Virtual Camera without having to remember which properties to copy and paste. This property applies to all Virtual Cameras. |
Priority | The importance of this State-Driven camera for choosing the next shot. A higher value indicates a higher priority. This property has no effect when using a State-Driven camera with Timeline. |
Look At | The default target GameObject that the children Virtual Camera move with. The State-Driven camera uses this target when the child does not specify this target. May be empty if all of the children define targets of their own. |
Follow | The default target GameObject to aim the Unity camera at. The State-Driven camera uses this target when the child does not specify this target. May be empty if all of the children define targets of their own. |
Animated Target | The GameObject that contains the Animator Controller. The State-Drive camera reacts to the animation state changes from this GameObject. |
Layer | The animation layer to observe in the Animated Target. |
Show Debug Text | Check to display a textual summary of the live Virtual Camera and blend in the game view. |
Default Blend | The blend which is used if you don’t explicitly define a blend between two Virtual Cameras. |
Custom Blends | The asset which contains custom settings for specific child blends. |
State | The list of animation state assignments for child Virtual Cameras. |
Virtual Camera Children | The list of Virtual Cameras that are children of the State-Driven camera. |