Switching Cameras Based on Animation States

addam davis
4 min readFeb 27, 2023

Objective: Understanding the functionality of a State Driven Camera.

State driven camera is a camera that changes its current state, or virtual camera that it is using dependent on the animation state of your character. This is great for when you're running, and you want to transition from a close-up 3rd person to a further back view. More commonly, this is used in 3rd person shooters, and you want to aim your gun.

In order to do this, we need to have an animation system for our player. We can set this up with two states.

Create animation, this is going to be an empty idle. Create a second animation.

Now select our “player” and drop your animations in the inspector and this is going to create your animator.

Inside the animator we are going to create two states. Drop the two animations into the Animator.

Create a bool parameter.

In this bool we want to set it up for when the bool is true, we go to state two and when false we go to state 1.

Now we have a transition between the two states. This is where we can start adding in our camera system.

Create state driven camera system.

Create a second child camera inside the state driven camera.

First camera is going to be a 3rd person camera. Select the player as the follow and the aim as same as follow target. This is going to be our further back 3rd person camera.

The second camera is going to be set to 3rd person, and this is going to be an over the shoulder camera.

Now we can go to the state driven camera and create a list. We can add two new states. The camera 1 and camera 2. We are going to need to have an animated target. That target is our player.

You’ll now notice you have state 1 available and state two.

If you play the editor and select the boot your camera will now switch to the closer camera, and back if you select it again.

The delay is because we forgot to turn off the exit time on the animation transitions.

This is a state driven camera.

--

--