Everything in your Unity project passes through the lens of a camera, so you need to squeeze everything you can out of that camera. While much of this magic is expressed through render pipelines – light, shadow, focus, color – other dimensions are critical: camera position, motion, and timing.

Cinemachine is Unity’s virtual camera operator, a tool for ensuring that your camera captures the action exactly where and when you need it. Made for both games and animations, 2D and 3D, Cinemachine makes your camera smarter so that the action and emotion is always captured by the lens.

We want to share some of the latest developments with Cinemachine. We’ve become a verified package (more on what that means below). We have a new version coming out with some fun and useful features and samples. And we have a live talk coming up as part of Unite Now that you can join from the comfort of your home.

Live talk: Cinemachine in the trenches

Join us at 9 am PT on Thursday, May 28, via Zoom as part of Unite Now, Unity’s free series of online learning sessions, demos, creator stories and more.  We’ll be talking with a few of our most demanding customers about how they’ve achieved their results with Cinemachine. The conversation will be followed by a live Q&A. Register here to attend.

If you miss the live show, you can check out the recording on YouTube later.

Cinemachine 2.5 verified for Unity 2020.1

Cinemachine has been around for a long time, both as a Unity package and before that as an asset in the Asset Store. As a “verified” package, it has proven its mettle both through internal QA and through user validation.

What does this mean for you?

While no feature can claim to cover every use case, verification indicates that we’ve considered a lot of use cases and we’ll prioritize bug fixes to ensure those cases remain supported. The Cinemachine team has always taken its commitment to users outrageously seriously, and you’re always welcome to ask us for help on our forum.

Verification also points to a future in which we’ll be better able to serve you with Cinemachine included in project templates and more educational material.

Cinemachine 2.6 in preview

No sooner was the code dry on 2.5 than the team started work on 2.6, which is now in preview. There are some new features, but perhaps even more useful are the new samples, which help you get up and running for key use cases like aiming (in third-person shooters) and dual targeting.

To create a new project, install Cinemachine and the new samples, and follow along.

Workflow improvement: Virtual cameras now created at scene view 

We’re pleased (and a tiny bit embarrassed) to open with this astonishingly simple but really useful workflow improvement: whenever you create a new virtual camera, we drop it in exactly where your scene view is.

Placing the camera exactly where you are in the scene makes blocking and framing shots much easier and more intuitive, speeding up your creative workflow.

New feature: Impulse propagation

An important effect for achieving realism in digital camera work, useful both in games and in cinematics, is when actions in the environment jostle the camera. In the real world, we tend to worry about it the other way around, using tools like a Steadicam to dampen this effect. But when the connection between the environment and the viewer’s perspective is lacking, the virtual world can seem stiff and unresponsive.

We provide a couple of ways to connect camera motion to the physical action in the scene. One of these is the Impulse, which consists of a Noise Setting (a pattern for generating shake), an Impulse Source (the location in the world that creates a disturbance), and an Impulse Listener (the thing affected by that disturbance). Note that the listener doesn’t have to be a camera, so you can use this system to disturb other objects as well (see the example below). For Cinemachine 2.6, this tool includes an added layer of realism, propagation speed, which allows you to modulate the timing between when a disturbance occurs and when it affects the listener.

For this example, we first keep the propagation speed low, so you can see the effect clearly, before ramping it way up to show something more akin to the effects of a realistic explosion.

If you downloaded the Samples, you’ll find a sample scene in your project at Assets > Samples > Cinemachine > 2.6.0-preview.5 > Cinemachine Example Scenes > Scenes > Impulse > ImpulseWave. (Note that the version number might have changed by the time you read this.)

New sample: Third-person aiming rig

One big difficulty with games like third-person shooters is the slight (but significant) disconnect between the perspective of the character and the player’s camera. Anyone who has played such a game and lurked around a corner or behind an obstacle, waiting for a clear moment to attack, has experienced this disconnect. But in games where the camera is well managed, you probably don’t find it problematic.

In Cinemachine 2.6, we’ve added the sample scene Assets > Samples > Cinemachine > 2.6.0-preview.5 > Cinemachine Example Scenes > Scenes > AimingRig > AimingRig (the version number might be updated). The example demonstrates a great setup to achieve a AAA-quality look for this common use case.

The video above highlights how to construct such a rig with the help of the 3rd Person Follow behavior and a Cinemachine 3rd Person Aim component. The component references a sprite as the reticle that denotes where the character is looking, and it uses a raycast to position that reticle. In the video, you can see the difference between the camera’s perspective (the larger circle) and where the character is looking (the smaller one). It’s a minor offset, but it can be critical when a player is trying to judge aim.

Note also that the Cinemachine 3rd Person Aim component provides filters for what the raycast will ignore, and a distance setting to limit how far the ray is cast.

New sample: Dual-target rig

Another common use case: you want to drive the position of the camera by following a GameObject – a tank, a car, an avatar – but drive the aim by chasing another object that represents a point of interest, such as the tank’s aim. As with the aiming rig, we’ve set up a reticle, but this one does some fancy indirect chasing of the mouse within a set of limits. Then there’s a Virtual Camera following the reticle. Check out the video below.

The example is available at Assets > Samples > Cinemachine > 2.6.0-preview.5 > Cinemachine Example Scenes > Scenes > DualTarget > DualTarget (the version number might be updated).

This is a great illustration of how you can use indirection with Cinemachine to create complex behavior. There are a few moving parts here:

  • The CM Dual Target Virtual Camera follows the Player object, but it looks at the AimTarget Moved by Mouse object.
  • The Gun Points at AimTarget object has a simple script on it called PointAtAimTarget, which points the gun at the AimTarget Moved by Mouse object.
  • Finally, the AimTarget Moved by Mouse object – the thing everyone else is looking at – itself has a MoveAimTarget script.

The camera following the Player object is pretty self-explanatory. Wherever the Player goes, the camera will follow with appropriate offsets. Similarly, the look at behavior simply ensures that the camera looks at the reticle. Note that the Dead Zone and Soft Zone parameters are set almost wide open (and exactly the same as each other), so the reticle can move freely within the screen-space without causing any motion. Only when the reticle gets close to the edges does the camera react.

PointAtAimTarget, the script on the gun, does literally what it says on the tin: it ensures that the gun points at the target.

So the only somewhat complicated piece is the MoveAimTarget script. As was the case with the third-person animation setup, we have references to a sprite (for the reticle) as well as information about how far to raycast and which layers and tags to filter from the cast. Additionally, we’ve added details for tuning the reticle behavior, including which input dimensions should drive the behavior.

New sample: Camera magnets

Camera magnets sound like a new feature, but really they’re just a refined example of using weights in a CinemachineTargetGroup. This use case, suggested by a user on our forums, is fairly common: your camera wants to follow a target (your avatar, perhaps) until it gets close to a point of interest. As you approach that point, you want the camera to gravitate towards the point of interest. Let’s watch the video and then we’ll explain how it’s done.

Our virtual camera this time is not focused on a single object, but rather on a CinemachineTargetGroup. Target groups are an incredibly useful and versatile abstraction in Cinemachine. Instead of pointing a camera at one thing, a group allows you to point it at multiple things. This comes in handy, for example, if you have a party of adventurers who spread out and you want to keep them all in the shot.

But each target in the group also has a weight, so you can bias the camera towards objects whose weight is greater than others. In this example, we demonstrate how playing with that weighting dynamically allows us to “magnetize” objects as we approach them.

Two exceptionally simple classes allow this magic to happen: CameraMagnetTargetContoller (attached to the CameraMagnets GameObject), and CameraMagnetProperty (attached to each of the CameraMagnet GameObjects). Each CameraMagnetProperty sets a proximity and strength to control its weight in the target group. The CameraMagnetTargetContoller then loops through all the magnets. Added into the mix is the player avatar itself, which has a constant weight value of 1. If there are no magnets attracting the camera, the avatar “owns” the camera’s attention. But as the player approaches, the magnets pull more strongly, drawing the attention towards these key positions.

Improvement: Better lookahead

Smoother, more predictable, and more efficient. Lookahead is a powerful feature that can give a better view of where the target is going. We think the new implementation has a more human feel to it, and more users should take advantage of this feature.  

Improvement: Better support for input systems

While it was always possible to use Cinemachine with custom or third-party input systems to control the camera, doing so was sometimes a little awkward and not so easily discoverable. You had to override the global delegate CinemachineCore.GetInputAxis(string name) to point to your custom input provider function. You can still do that, but it’s no longer the best or most efficient way.

Now there is a new interface Cinemachine.AxisState.IInputProvider. If a virtual camera has a behavior that implements this interface, then that behavior will be queried for input instead of the standard CinemachineCore.GetInputAxis(string name) delegate.

The advantages of this are that the interface call is not string-based and that it calls a per-virtual-camera implementation that can have its own data, so it can be set up for efficiency and for mapping to specific players.

Cinemachine 2.6 ships with an example implementation of this for Unity’s new input system. You can either use it directly as-is or use it as a template for your own custom input providers.

If you have the new Input System package installed, then you will be able to add the new CinemachineInputProvider component to your virtual camera. With it, you can simply and easily map your camera’s input to an Input Action Reference and support multiplayer requirements.

Stay connected

Cinemachine is all about making your game, movie, or cutscene look amazing, and we hope you find all the new features, improvements, and samples useful in making your games as gorgeous as they can be. Download the Cinemachine 2.6 Preview now. 

Let us know what you think, what works for you, and where we can do better. Join us in the Cinemachine forum, where we can answer your questions and get you the results you need.

Finally, mark your calendar: our live Cinemachine session, part of Unite Now, airs at 9 am PT on Thursday, May 28. You can register now.

Source: Unity Technologies Blog