In this article, we are going to cover the Cinemachine virtual camera’s aim settings.
Once you have imported Cinemachine using the Package Manager, we are going to create a virtual camera.
This will populate a virtual camera into the hierarchy, CM vcam1, and in the properties of this virtual camera there is a Look At option. requires a transform for the camera to look at and you can drag in a game object that you would like to focus on. For my example, this is going to be Banana Man.
I create a simple movement animation for the Banana Man and you can see how the virtual camera continues to look at the Banana Man as he moves.
The virtual camera has a few other options I want to cover before diving into the aim settings. The Game Window Guild will bring up a viewing guide to help visually depict the aim settings and you can see this in the further below. Save During Play when selected will save any changes you make to the virtual camera while it is in Play mode, instead of it being reverted back to the original settings values before Play mode was entered. Lastly, the aim section which controls the Look At feature of the virtual camera.
We are keeping it in Aim in Composer.
Track Object Offset
This will centered the camera at a global offset depending on the x, y and z values.
The image below shows how the virtual camera lags behind the object it is looking at. This can be a problem when the player is moving left or right and cannot see what is in front of them.
The lookahead time will calculate how much further ahead the camera should focus on depending the objects movement.
As the Lookahead Time is increase, it will cause the camera movement to become more jerky. This is where the Lookahead Smoothing comes into play. It will smooth out the movement.
The Lookahead Ignore Y is for top down games and prevents the gimble locking, so if you are not making a top down game you can ignore it.
Horizontal and Vertical Damping is the easing of the camera movements on those two axis.
The image below shows the horizontal and vertical damping set to 0 and same with the Lookahead Time. You can notice how the camera is locked on the object and the movement is harsh.
Below the horiztonal and vertical damping is incremented, which results in an easing of the camera movement in those directions, but the camera is now lagging behind.
Damping should be used with Lookahead Time to achieve a smoother and organic camera movement.
Screen X & Y
Screen X and Y have to do with the position of camera guide.
Image below shows the adjustment of the screen X and screen Y.
The dead zone is the area where the camera will not move if the object that it is looking at is in the dead zone.
The clear area of the Game View Guide is the dead zone. If the object is in that area it will not move, but once it leaves that will trigger the camera to move towards it.
In the image below, you can see the dead zone in action.
The blue area is the zone that will take into account the horizontal and/or vertical damping.
In the image below, you can see the object leaving the dead zone before the camera moves because vertical and horizontal damping has been applied.
The soft zone is the area that will trigger the camera to move regardless of damping.
The soft zone is depicted with red in the Game View Guide. Once the camera focus hits this zone it will automatically move no matter what.
The image below shows the soft zone resized and how it forces the camera to move when the focus enters it.
Bias X & Y
The bias x and y adjusts the positioning of the soft zone.
Below you can see how adjusting the bias will move the soft zone around.
Those are the virtual aim settings and it is important to understand how these settings work and interact with each other to get the most out of cinemachine.