Aiming Features in Cinemachine
Aiming Features allow your Virtual Camera to actively rotate in the direction of a given object in your scene with various options to modify the rotation behavior. This allows your object to always be in camera view despite moving in any given axis.
Objective: Learn how to make a virtual camera rotate in perspective to a specific object and modify its behavior.
Table of Contents
· How to Aim Your Virtual Camera
∘ Look At
∘ Look Ahead
∘ Horizontal and Vertical Dampening
∘ Positional Constraints
∘ Zone Constraints
How to Aim Your Virtual Camera
Look At
We’ll take a look at this step-by-step as always:) but first I need to make sure that you know how to step up your virtual camera ← so give that 2min article a check if you’re unsure.
Select your virtual camera, in the Inspector you will see a Look At slot which takes in a type Transform(and object). Drag that object to this slot in your Inspector.
Drag the object you wish into this slot.
If your object is animated and you press Play, this alone will make the camera rotate in its direction keeping it in view. However, there’s is more to be explored when it comes to Aim Properties, let’s take a look!
Open up your Aim Settings
Once you do, these markings will appear on your game view, I’ll be explaining those as we explore the aim features.
For now, we’ll stay with the Composer Aim mode. You can learn more about these properties here.
Look Ahead
When I press play, notice how there is a tiny yellow square directly at the center of my cube. This means that the camera is centralized on the object and therefore will always keep it in the middle. This is an inherent behavior from the Look at Slot where we placed the cube earlier.
But what if we’re working on a game where the camera needs to be ahead of the object rather than starkly on it? That’s where look ahead comes in.
- Look Ahead comes in the form of a slider in the Aim Settings. By adjusting this, you can choose just how ahead your camera will be.
Now our yellow square is ahead of the object denoting the camera’s movement.
But this looks weird and jerky doesn’t it? Let’s fix that!
3. Use the Look Ahead smooth so that the movement is more subtle and less of a sharp jerk from the camera.
Note: You can play around with these values to see what works best for your projects.
Now, the movement isn’t so unnatural.
Note: If you happen to be working on a top-down game, you really want to be mindful and avoid things like gimble lock. Luckily By tweaking this option, you can do just that.
Horizontal and Vertical Dampening
Both of these properties are linked to Look Ahead, their purpose is to cause a sort of delay in how long it takes for the camera to rotate toward the object in the given directions. Let’s take a look at this in action.
Without Dampening:
With Horizontal and Vertical Dampening
Positional Constraints
I want to take a look at these four properties in a rapid-fire bulk as they accomplish similar tasks.
Screen X and Screen Y
These properties essentially lock the camera view into the respective axis.
Bias X and Bias Y
Similar to Screen X and Y, this will lock the view to a specific axis, however, with Bias, this is done by actually repositioning the guidelines of the Aim Settings rather than changing the camera’s rotation as a whole.
Here you can see how using Screen X moves the Camera as a whole. When using Bias, the camera’s physical rotation does not change.
Zone Constraints
The Zone Constraints are all about the guidelines you can see in the Game View. Let’s take a look at what each of these does!
Dead Zone Width and Height
You can create a boxed area by manipulating the sliders.
The effect of a Deadzone is that no camera movement will take place until the object hits one of the edges of this box. Once that happens, the camera rotation will shift to follow the object. If you apply Dampening, the object usually goes inside the blue area rather than just the edge and that’s when the movement will take place.
Soft Zone Width and Height
The Soft Zone is the red margin that surrounds all other zones.
I like to think of it as “the end all” area because any modifiers such as dampening will completely cease when they hit this zone and camera rotation will immediately take effect. Note that when I say “cease” I don’t mean that it will remove the effect, but rather that movement will take priority.
The following camera has vertical and horizontal dampening, however, you can see that movement immediately resumes as it hits the red margin, Soft Zone.
That wraps up our look inside Aim Properties!
In the coming articles, I will continue to explore the wonders of Cinemachine — I hope you have found this information valuable! Follow me for more Unity Development articles! :) I am a video game narrative designer on a journey to learn more about Unity Development and Software Engineering.