Don't script the Camera! Use Cinemachine! [Unity Essentials]

We need to talk about Cameras …

Quite frequently someone steps by and asks a question about a simple camera script, be it first person, third person, top-down, free look, orbit, path follow …

The question is typically one of the fundamental kind, like how to rotate the camera correctly, how to clamp the rotation range, how to avoid collisions.

These are solved problems!

Use Cinemachine!

The Cinemachine package provides you with built-in first person and third person camera handling. In fact, many other camera types are included or at least demoed in the package’s Samples (install them via Package Manager).

You also get collision avoidance, camera noise and effects (shake, wobble), zoom, smooth blending between cameras, separate follow and look-at targets, keeping the character (or several!) centered with a soft follow, safe zones, and so much more.

Of course that makes the package seem daunting at first - but you only need a small fraction of it and almost everything can be neatly configured via the Inspector. Be sure to watch the Cinemachine Playlist:

Cinemachine is demoed in the free First Person and Third Person Starter Assets. It is playing a part in the free Game Design Playbook too.

So the next time you wonder “how to do X with the Camera?” you know you better ought to use Cinemachine. Even if you need a custom-scripted camera behaviour you can still leverage a lot of features from Cinemachine.

I repeat: you do not script the Camera. Not without Cinemachine. Or more commonly: not at all, thanks to Cinemachine!

5 Likes