An Introduction To Cinemachine And Virtual Cameras In Unity

Adam Reed
3 min readMay 16, 2021

--

Cinemachine is a powerful tool within Unity for creating interactive camera movement and advanced camera behavior without needing much (if any) programming.

Cinemachine controls your camera similar to a Director in a movie. It allows you to create a dynamic camera system using “Virtual Cameras” to create cinematic shots which is what we will be doing in this article.

You can find and install the Cinemachine package from within the Unity “Package Manager”.

Once you have installed the Cinemachine package into your project, you should see a tab labeled “Cinemachine” appear on your toolbar. This tab allows you to create a variety of different Cinemachine Cameras.

To create a standard “Virtual Camera” just hover over the Cinemachine tab on your toolbar and select ”Create Virtual Camera”.

Once created, you should see a new “CM vcam” object appear within your hierarchy. It will contain a transform and a “Cinemachine Virtual Camera” component.

The priority level works kind of like layers and establishes which virtual camera will be the one shown as the primary camera

You can set the “Look At” parameter by dragging and dropping a game object from the hierarchy into the “Look At” box. The virtual camera will always face that object. You can do the same with the “Follow” setting as well.

When you create a Virtual Camera in your project for the first time, a component called “Cinemachine Brain” will automatically generate onto your “Main Camera” assuming that this component does not already exist.

The “Cinemachine Brain” component attaches to the “Main Camera” and allows for transitions between “Virtual Cameras” by setting the Main Camera’s transform position/rotation to that of the Virtual Cameras.

[Pro Tip!]

If you select the virtual camera you just created so that it is highlighted in the hierarchy, you can automatically align its position and rotation to your viewpoint within the scene view’s position and rotation by typing Ctrl+Shift+F or by selecting GameObject>AlignWithView from the toolbar.

While we can use Cinemachine’s “Virtual Cameras” to compose cutscenes/cinematics for use within “Timeline”, we can also use Cinemachine’s “Free Look Camera” to create powerful and versatile player camera systems. This is something we will be going into further in another article down the road. But until then, thanks for reading, and don’t forget to check out my next article where we will be delving into the second half of the cinematic process as we begin working with Unity’s “Timeline”!

--

--

Adam Reed
Adam Reed

Written by Adam Reed

Hi, my name is Adam Reed and I am a software engineer specializing in Unity and C# development. Feel free to scroll through and check out some of my work!

No responses yet