3rd Person Follow Virtual Camera Explained in Unity’s Cinemachine
Objective: To understand what the 3rd Person Follow virtual camera is in Unity’s Cinemachine and how to use it.
Please join me in this 6 part series that is going to look at Unity’s 6 different Body Settings available in Cinemachine’s Virtual Cameras, with examples. I have previously touched on a few of these in some detail, but just for fun let’s dive a bit further into the settings and get some examples flowing.
‘Body’ refers to the movement of the virtual camera in the scene and works hand in hand with the ‘Follow’ target field, covered in this article.
Whereas ‘Aim’ (as covered in this article)refers to how the virtual camera aims and tracks the ‘LookAt’ target.
If the ‘Follow’ target field is left empty (apart from not having a target to follow, obviously), you will also be met with this error:
When a Follow target is placed into that field:
Problem solved! Keep this in mind for the rest of the series also.
3rd Person Follow Camera
If you are unfamiliar with the term 3rd person in gaming, it is essentially looking at your character from a distance (as an onlooker) and not from the viewpoint of the character directly. Case in point below:
Now for Cinemachines virtual cameras, the 3rd person camera is going to stay in a locked offset position relative to the Follow target, even when the character moves and rotates.
These settings can be adjusted so that the camera can have a different offset position, damping effect or even obstacle layers/tags where the camera doesn’t collide with. Let’s take a peek at these below:
3rd Person Follow Settings
The 3rd person camera setting position is defined by 3 different pivot points — The origin of the ‘Follow’ target (A), the shoulder (B)and the hand (C) .
The hand is vertically offset in relation to the shoulder. This photo is quite deceptive, the red line is actually a straight line behind egg man.
I have previously covered damping in this article, but I will also touch on it here. Damping looks at how quickly the virtual camera reacts to the movement of the target (egg man) on the X, Y and Z axis. The smaller the number, the more responsive the camera is to the targets movement.
Below, the damping settings are all set to 0. Notice that the virtual camera movement is very crisp and responsive.
Now if we increase the damping to 10 on the Z axis (which is the way egg man is running), notice that the virtual camera is almost trying to catch up and it is lagging behind.
The shoulder offset is a local space pivot position that is calculated relative to the ‘Follow’ targets origin position.
E.g. If I was to set all the X, Y & Z shoulder offset positions to 0 (and in conjunction with a camera distance of 0), then the virtual cameras position will be the ‘Follow’ targets origin position.
Vertical Arm Length
This is the vertical offset of the hand relative to the shoulder and is the A in the picture above.
The camera side refers to which side of the ‘Follow’ target it will sit or somewhere in the middle. Over the left shoulder being 0, right shoulder +1 and anything in between.
This gif shows the movement from 1 to 0 (right to left):
This refers to the distance from the hand (A) to the camera.
Camera Collision Filter
The camera collision filter will avoid collisions with game objects on the specified layers:
Watch as the camera sharply darts to the side to avoid a collision with the rock which has a layer called ‘Obstacle’ on it. How sharply the camera will jump is also dependant on the camera radius (below):
The camera will auto adjust once it is around the obstacle to go back to the set offset position.
Compared to the above, obstacles that have a specific tag will be ignored.
It seems that through some testing, if I was to have a camera collision filter on the rock game object (to avoid colliding with the rock) and also an ignore tag (so the camera went straight through it), it ignores the initial and obeys the latter (maybe cancelling each other out), as shown below:
The camera radius refers to how close the virtual camera can come to an obstacle, between 0.001 and 1. The lower the number, the closer it can get and vice versa (as shown above in the camera collision section).
Can you use the 3rd person follow camera to create a first person camera?
The simple answer is Yes! A very basic one. If you were to adjust the shoulder offset and camera distance position in the Rig section so the view is from the characters, then mission complete!
How Would We Make Changes at Runtime Through Scripting?
Great question you asked! Let’s take a quick look.
Normally when we are trying to access these settings through scripting you would get there through the CinemachineVirtualCamera component (which is very logical, and is the correct way to access these settings shown below):
However, when trying to adjust the Body and Aim settings, they have their own built-in classes:
Now, if you got through this whole article and were more interested in the 3D low poly animated egg that will be the focus of this 6 part series, then please head over to the asset store and show the creator some love (link below).