Cinemachine || Switching Cameras Based on Animation States

Pavel G Rodriguez Garcia
4 min readMay 30, 2023

--

To switch cameras based on animation states there first needs to be an animation system set up on your character, I set one in the capsule by right clicking on the Hierarchy, create, and then selecting animation:

I then duplicated the animation with Ctlr + D , renamed the second one to New Animation2 and dragged the first animation to the capsule which automatically added the Animator to the capsule:

Clicking on the Controller option should now give you access to the animator window:

I renamed the New Animation to State 1, then right clicked and created a new empty state and named it State 2:

With State 2 now selected I then dragged New Animation 2 to the ‘Motion’ option:

I then connected the transitions by right clicking and selecting ‘Make Transition’ and dragging the arrow to one, then the other:

Next under the parameters tab in the animator window I created a bool by selecting the ‘+’ icon and selecting Bool:

With the bool now made, back in state one I selected the Transition tab/option:

Clicking on it expands the options available:

Under the conditions tab I selected the ‘+’:

And that automatically made it so that when the Bool is set to True, the state 1 will transition to state 2. Then I repeated the same process with State 2 but in reverse:

With that set up I right clicked on the Heriarchy and created a new cinemachine State Driven Camera:

With my state driven camera now created, I went to the Virtual Camera Children option and added a secondary camera:

In the first VC I changed the settings to 3rd person follow and adjusted to follow a bit behind the capsule/player:

I then adjusted the settings of the second camera to also be 3rd person follow but with a more zoomed in look:

Back in the StateDriven Camera, I added 2 new states and for the first one I set the first child cam (CM vcam2) and the second one I set to the second child camera (CM vcam3), the settings would not allow me to set the State to state 1 or 2 until I had selected the ‘Animated Target’ which is the capsule, but after dragging the capsule to the ‘Animated Target’ option I was able to set the State 1 and State 2 to the corresponding cameras:

Now with all that set up the cameras can switch based on which state the animation is set to:

This would be a good way to have your cameras similar to Mass Effect where when you would aim the camera will zoom in, but when not aiming it just acts as a normal 3rd person camera!

--

--