The Cinemachine State-Driven Camera activates a child Virtual Camera when an animation target changes states. This means you can have different camera playing when the player dies, a different camera for when the player is aiming and a different camera for when the player is moving.
The example above shows three cameras being used; one for moving, one for aim, and one for death. The State Driven Camera knows which camera to activate when those animations are played.
State Driven Camera
Lets get start by creating a State-Driven Camera
This will create a State Driven Camera which will be parent of a Virtual Camera. You can add more Virtual Cameras to the State Driven Camera as children.
I will have 3 Virtual Cameras and I renamed to what they will do…
1 . Aim Camera = First Person View
2. 3rd Person Camera = Over the Shoulder View
3. Death Camera = Top Down Circling Dolly
Looking at the Player’s Animator, I have three animation states that will use the 3rd person camera (Idle, Walking, Run), one that will use the Aim camera (Pistol Idle) and one that will use Death camera (Death).
The State Driven camera will give you the ability to switch between the different state cameras (Aim, 3rd Person, Death) depending on which Animation state the player is currently in.
You will need to assign the Animator you want to assign the cameras to the Animated Target.
Once you have the Animator assigned you can start to match the animation State with the camera you want to use when in that state.
Below you will see how the cameras will switch depending on the animation state of the player.