Unity and Cinemachine — Virtual Camera Aim Options

Joshua Nielsen
5 min readMar 14, 2022

--

A look at the virtual camera’s “Look At” options

Photo by Dids from Pexels

We continue our examination of Cinemachine in Unity today. This time, we’ll be exploring options for our virtual cameras when they are “Looking At” something.

Amongst other options, virtual cameras can be configured to focus on a specific object in-game. This can cause the virtual camera to change its position and/or rotation, depending on what options are selected.

When a virtual camera is configured to do this, new options are opened to dictate how the virtual camera will go about its job. In this article, we’ll be looking at the options that are opened when a virtual camera’s Look At field is filled.

Initial setup

To explore the Aim virtual camera options, we need two things. First is a game object to Look At. Go ahead and add a simple 3d object to your scene, such as a sphere or cube.

The second thing you need is a virtual camera. Add one to the scene using the Cinemachine menu. When you create the virtual camera, you may notice you have two warning symbols on your virtual camera by default.

A new virtual camera with default settings

The Body and Aim sections are looking for something to be in either the Follow or Look At fields, respectively. If their respective fields are populated, or the drop down set to “Do Nothing”, then the warnings will go away.

Since we want to check out the Aim section, we need to enter something into the Look At field. Drag your 3d object into that field, and make sure to set Body to “Do Nothing”.

The Look At field

When a game object/transform is entered into the Look At field, the virtual camera will immediately change its rotation to be pointed directly at that object. In addition, the virtual camera will now be constantly checking if the specified object has moved and will continue to change its rotation to keep that object in view. It will not change its position.

The primary virtual camera has been set to Look At this blue sphere

Next to the Look At field we have a drop down menu with several options. By default, “Composer” is selected. Here’s a quick run down of the potential options:

  • Do Nothing: The virtual camera does not rotate to follow the target.
  • Composer: Keeps the target in the camera frame.
  • Group Composer: Keeps multiple targets in the camera frame.
  • Hard Look At: Keeps the target in the center of the camera frame.
  • POV: Rotates the camera based on user input.
  • Same As Follow Target: Settings are coming from the Body section.

We’re going to keep this set to the default of “Composer”. This allows us to fully examine the Aim options without added complications such as having a group as a Look At target.

The Aim options

With a game object selected for our Look At field, and Aim set to “Composer”, we can now see all of the options for modifying our virtual camera’s behavior.

The CinemachineVirtualCamera Aim options

Let’s look at each option individually.

Tracked Object Offset: The offset from the center of the Look At target. If you need your camera to be pointed at a spot other than the center of the target object, this is the field to modify.

Lookahead Time: Adjusts the offset based on the motion of the Look At target. This means the software attempts to predict where the target object will be in the future and the camera moves in response to that prediction.

Lookahead Smoothing: Controls the smoothness of the lookahead algorithm.

Lookahead Ignore Y: Toggles whether or not to ignore the Y-axis in lookahead calculations.

Horizontal and Vertical Damping: This value represents how responsive the camera is in following the target in either the horizontal or vertical directions. A low value means that the camera responds very quickly to movement by the target object.

Screen X and Y: The coordinates on the screen that the target object is expected to be centered on. For example, if you had other UI elements on the edges of the screen and you wanted to center the target object in the portion without UI elements.

Dead Zone Width and Height: The dead zone is the term for the portion of the screen in which the camera does not respond to the target’s movement. For example, if you had a modest sized dead zone, minor movements of the target would not trigger a response in the camera.

Soft Zone Width and Height: The soft zone is the term for the portion of the screen in which the camera will move to return the target object to the dead zone, but the horizontal and vertical damping values (see above) determine how quickly this is accomplished.

Bias X and Y: Shifts the center of the dead zone relative to the soft zone. The use cases for this are similar to that of the Screen X and Y fields.

Conclusion

As we can see through this examination of the Aim options, we can accomplish a lot just by carefully configuring our virtual camera options. It’s a very powerful tool, and I recommend playing around with the various options to better understand how you can make the best use of these options in your own project.

Next time, we’ll be doing a similar examination, only this time with the Body options for a followed object. Until then, thanks for reading.

--

--

No responses yet