Cinematography In Unity — Cameras In Cinemachine

Joshua Nielsen
4 min readDec 17, 2021

A quick look at managing cameras in Cinemachine

Photo by Martin Lopez from Pexels

Our examination of cinematography in Unity continues with our first look at the Cinemachine package in Unity. What do I mean by cinematography in Unity? By that I mean the intelligent use of Unity cameras and visual tricks to make the best looking games we can.

What is Cinemachine?

Cinemachine is a package available for Unity that provides tools for managing in-game cameras. Without it, we may need to do a lot of development work to get the functionality we want for our cameras.

Cinemachine is freely available for all Unity projects. To install it, make use of the Unity package manager (which can be found in the Window menu).

Making Cinemachine cameras

Once you have installed the Cinemachine package into your project, you should see a new menu option in the menu bar titled Cinemachine. From this menu, we can easily create new Cinemachine powered cameras for our Unity projects.

Go ahead and select the “Create Virtual Camera” option from the menu. Doing this will generate a new Unity game object with the Cinemachine Virtual Camera component.

A new Cinemachine virtual camera

That’s all we need to do to make one. Easy, huh?

As you can see from the Inspector window, reviewing every aspect of just this type of camera would be a major undertaking. That said, I would like to at least give you a brief rundown of how to accomplish some basic actions with the Cinemachine cameras.

Positioning your cameras

The Cinemachine cameras are Unity game objects, and as such can be moved and rotated in all of the same ways as any other game object. We can manually adjust their transform in the Inspector window, or we can use the tools in the Scene window to manipulate the camera objects.

All of that is probably not anything new for anyone reading this article, but what might be new is using the “Move to View” command to align your cameras exactly as you want them. What is that command, you might be asking? Let’s examine it while using it to position our camera.

Within the Scene window, find something you want your camera to be pointed at, then line up the view in the Scene window in exactly the way you would like the camera to be aligned. Once that is done, select the virtual camera in the Hierarchy and then use the “Move to View” command. The “Move to View” command can be found in the GameObject menu, or you can use the shortcut Ctrl+Shift+F.

This configures your camera object to be in the exact position and rotation that you were at in the Scene window. This is an ideal way to position static cameras exactly as you would like them to be.

Dynamic cameras

So that’s good for static cameras, but maybe we want the camera to move about? Well, the cameras are just game objects, so they can move in any of the ways a game object can move. However, I did want to highlight a couple of features of the virtual camera that we can see in the picture above: Look At and Follow.

These act exactly as you’d expect. All we need to do is input another game object into the desired field and Cinemachine does the rest for us.

Let’s say we create a new game object, a sphere, and we use that as the input in the Follow field.

A Cinemachine camera set to follow an object

As you can see in the Game window, the camera follows the sphere automatically. Cinemachine has just saved us who knows how much time and effort. Let’s try the Look At field next.

A Cinemachine camera set to look at an object

Works like a charm, and it couldn’t be simpler to use.

Managing multiple cameras

In the course of developing our projects, we may find ourselves in want of multiple cameras. Creating multiple cameras is not an issue, but how do we determine which camera is in use?

This is where the Priority field comes into play. Whichever camera has the highest priority value is the one that will be showing in-game.

In addition to this, if we need to focus on a particular camera while working on our projects, but don’t wish to change priority values, we can use the Solo button in the Cinemachine Virtual Camera component. While this button is selected, the camera it is a part of is the focal camera.

Conclusion

I hope this article served as a good introduction to the capabilities of the Cinemachine package. As I’ve stated earlier, the work we would have to put in to replicate similar functionality would be considerable. And it’s all freely provided to all Unity users!

Next time we will start looking at Timeline, a feature of Unity that allows us to more easily put together sequenced events. Thanks for reading.

--

--