Creating Over The Shoulder Aiming in Unity

Aidan Hart
4 min readMay 13, 2024

Today, our goal will be to use different virtual cameras based on which animation state is being used. Before we begin however, we’ll be using the player armature from these unity assets you can download here.

Walking State

The first thing we want to do is actually add our player armature. What we need to do is just take a look at our assets folder and search for the armature and its own camera called a ‘FollowPlayerCamera’

Inside the player armature, there will be an empty object called a player camera root. Have the camera we just added follow that empty object. When that is done, we will get our walking state.

Running State

Making our running state is a bit trickier. Now what we’ll need to do is set up a state driven camera and our walking state virtual camera to it. We’ll also create a second virtual camera to act as our running state.

What are state camera should look so far.

The running state camera should be the same as the walking state camera. Except the running state camera has a higher noise profile.

See how the camera is shaking when we start running?

Let’s move onto the next animation state, the aiming state.

Aiming State

For the aiming state we’ll add a virtual camera to our state-driven camera. We’ll have it to where we’re looking over the shoulder.

The virtual aim camera will be like the other two virtual cameras. However, it will have a different shoulder offset and will be closer to the armature.

For the hard part, we need to edit the animator our armature is using and have it communicate with a new script we’re making.

The first thing we need to do is make sure our animations are rigged properly. Be sure to set the animation type to ‘Humanoid’ and apply the changes.

With our animations now rigged correctly, we need to create a new bool parameter and a state that would use the aiming animation we just fixed.

Be sure to disable exit time in your transition paths.

Now in order to enable and disable our bool parameter, we’ll need to create a new script. This script will access our animator and will have a method that will enable and disable our bool parameter.

Death check is for the death state, which I’ll go over soon.

When we test our aim virtual camera, it will look like this.

With our Aiming state finish, we’ll go over one more virtual camera state. The death state.

Death State

Setting up our death state will be almost the same as our aiming state. We’ll add another virtual camera to our state driven one, we’ll add a new state and bool parameter in our animator, we’ll also create new variables and a method to communicate with our animator to change states.

The only difference however is that our last virtual camera will be a ‘Hard Look At’ camera that will face our armature once it dies.

For this article, I’ll play our death state by just pressing the “I” key.

When we test it, we get this.

There you have it. We’ve created four different camera states that can swap between each other when our armature uses different animations.

--

--