Unity 3rd Person Character Cameras

Let’s create a camera system that does 3 things:
1) Shakes when player is running
2) Zooms in when player is aiming
3) Zooms out from above when player dies

We’ve got a scene that includes a plane, Cinemachine, and the Unity Starter Assets 3rd Person installed. And we’ve imported a couple of animations from mixamo.com for aiming and dying.

We’ll use a StateDrivenCamera to manage our various cameras. So use the Create State-Driven Camera option on the Cinemachine menu. Add the PlayerFollowCamera from the 3rd Person as a child to the StateDrivenCamera and remove the default camera created by the StateDrivenCamera. Add two more Cinemachine cameras to the StateDrivenCamera.

First, the shake camera… This will be a 3rd Person Follow camera following the Player. With some tweaking and Noise + Recomposer extensions, we get this:

Ok, next the Aiming camera. Another 3rd Person Follow. Nothing fancy:

And finally the Death camera. This one is going to pan out as our player dies, so lets use the BlendListCamera and have it go from a close camera to a far away camera:

Close Camera
Far Camera
Death Camera

Ok, now to manage our states. Here we’ve added the default and Run states:

For the Death state, we add a new state and then drop our Death animation into the Motion for the state:

Now we just need to add a Trigger state:

And here’s the result:

Now for an Aim state… Create a new state and add the Aim animation along with transitions in and out:

We need a bool to designate mouse down and up so:

Assign the condition:

And then assign the condition to return from Aim:

And add some new states to our StateDrivenCamera:

Now we get this:

Aiming
Death

Time for a script to tell the State Driven Camera when to call those states. Add this script to the player and it’s good to go:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store