When adding animation to Player, you might wondering if there is a function that can make cameras switching based on animation states.
Well, that is what State-Driven Camera do.
In this tutorial, I would show you how this function work with animation states.
And Danny- the wrestler-dancer would help us demonstrading.
First, we would need at least 2 animation to complete this function, and also make sure these animation connected by parameter.
I’ve created a bool as a parameter to switch between these 2 animation.
Let’s test this out.
Now we have 2 animation with difference on motion, let’s add the cameras to it.
Adding State-Driven Camera
From dropdown menu of Cinemachine, select State-Driven Camera.
Take a look at the default interface of State-Driven Camera. The main difference of this object is Animated Target, which is also where we are going to import our animator of Danny.
As you can see, it shows “An Animated Target is Required”.
Let’s setting the cameras first.
Once finished cameras adjusting, now we need to assign Animator to State-Driven Cameras.
Then we can pair our cameras to responding animation state.
All done! Let’s play it and check the result!