How to Switch Between Cameras with Cinemachine and Timeline

Objective: To look at how to switch virtual cameras in Cinemachine using the cut and blend methods of Timeline.

I am going to look at couple options here with how we switch between virtual cameras in Cinemachine and Timeline. The first is going to look at simply letting the virtual camerasCut’ between each other, and the second will be a ‘Blend’ of virtual cameras moving smoothly between each other.

As we are going to be using Timeline for this, let’s get this into our scene. Go to Window → Sequencing → Timeline, drag the tab down the bottom, docking it.

Window → Sequencing → Timeline

The ‘Cut’

Now let’s create our Timeline sequence which is going to show an existing animation play out for our character Darren who is stealing a keycard from the sleeping security guard. We are going to be using 2 virtual cameras to capture the animation, one from over Darren’s left shoulder which will then cut to the second virtual camera which will be focused on Darren’s hand stealing the keycard.

To get started, we need to create a Timeline asset and a Director component:

This is very simple, you just need to have the game object highlighted in the Hierarchy that you wish to create this timeline on, and hit the ‘Create’ button (I am going to be doing this on an existing empty game object with the Transform being reset to 0, 0, 0). Next create a new folder in your assets directory called Timeline and then rename the file to ‘Sleeping_Guard_Timeline’. This will create a .playable file.

Now Timeline will have an updated screen:

And our Sleeping_Guard_Cutscene game object has a new component called ‘Playable Director’:

At this stage we don’t need to make any adjustments to this as we are happy to have this animationPlay On Awake’.

Timeline is now looking for the CinemachineBrain (as this is the component controlling all the virtual cameras) and as we have it attached to the Main Camera, let’s go ahead and drag this game object into the Timeline, creating a Cinemachine Track:

Now let’s add our first Cinemachine Shot by right clicking in the Timeline next to Main CameraAdd Cinemachine Shot. From here we can drag our first virtual camera (showing Darrens over the shoulder view) into the newly created field ‘Virtual Camera’ in the Inspector:

Let’s now do the same thing again and add our second Cinemachine Shot, dragging in the second virtual camera.

We now have 2 virtual cameras added to our Timeline Sleeping Guard Cutscene sequence. Let’s now change the duration of the first camera to 2.5 seconds by clicking on the Cinemachine Shot in Timeline and heading over to the Inspector and changing the duration field to 2.5. Now let’s also drag the second Cinemachine Shot next to the first, so after 2.5 seconds it will instantly cut to the second camera:

It’s now time to take a look at our animation play out and look at the cut between the cameras:

The ‘Blend’

Alternative to the ‘Cut’ option, we can have both of our cameras blend together over a period of time using Timeline and it honestly couldn’t be any simpler, and looks much nicer for this scene!

Jump over to the Timeline tab and simply drag the second Cinemachine Shot on top of the first and a new box will pop up (with a diagonal line through it), this is the blend time. The smaller the box, the shorter blend time etc:

Let’s check out the blend sequence between the 2 cameras noticing how the camera moves to the other camera along an invisible line (essentially blending them together):

--

--

--

Passionate Unity Game Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Don’t lose out to coupon leakage in iOS15 | Talon.One

Header image

Nested ViewPager2 Horizontal Scroll

Jpeg Viewer App For Mac

Swift Benefits

Why Swift Developers Don’t Need More Than MVC

iOS — Refactoring in Swift: Identifiers!

Apple’s new Lock Screen overhaul in iOS 16 is long overdue

CryptoX-My take on Cryptocurrency

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Chris Hilton

Chris Hilton

Passionate Unity Game Developer

More from Medium

How to Switch Virtual Cameras Using Only Cinemachine and Scripting in Unity

Unity : Cinemachine and Timeline (Part IV)

Creating a “negative” powerup

Using the Layered Lit Shaders to mix Texture Maps in Unity3D