Day 55 — First look at Timeline in Unity part 1
Hey and welcome!
It’s time to start looking into using timeline to make use of the virtual cameras we created before and put together a cutscene.
First we need to grab the Timeline window from Window > Sequencing > Timeline and then drag it below our game view in our layout. I recommend organising your layout for this so that it looks something like this:
This lets us check what our cameras are doing as we’re moving along the timeline. To get started with the timeline click on the Sleeping Guard Cutscene object you have and then click on the create option in the timeline window. On the left side of the timeline you’ll see what’s called a cinemachine track which has Main Camera (Cinemachine) in it. You may not start with one but if you have go ahead and delete it by right clicking the track as we’re going to add this in from scratch.
With the track cleared, click on the plus icon on the left and choose Cinemachine.Timeline > Cinemachine Track to get started with a fresh track. Drag and drop the main camera into the blank cinemachine brain box and then right click in the timeline to add a new cinemachine shot.
Click on the gear icon in the top right of the timeline to switch the view from frames to seconds and then adjust the cinemachine shot so that it starts from 0 seconds and ends at 2 and a half seconds as seen above.
With that adjusted and while your cinemachine shot is clicked on go ahead and drag and drop the OTS shot into the virtual camera box in the inspector:
This let’s our shot know which camera to make use of in the timeline. Do the same for the Mid shot making sure that it’s 2 and a half seconds long again and you’ll now have something that you can switch between when the timeline is playing. With those added you’ll notice that when the timeline is playing it’s a bit of a hard cut between cameras, if you wished you could blend these together by making the Mid Shot overlap with the OTS Shot so the camera moves something like this:
Pretty cool right? Last thing before I leave you may have noticed that our animation clip is playing in the above gif while the timeline is moving along. In order to have that working for yourself click on the plus icon in the timeline and choose the Animation Track option. Drag and drop the animation itself that’s within the Sleeping Guard Cutscene object into the animator box.
Next click on the three vertical dots in the right side of the animation track and click on the Add From Animation Clip option. Search through the explorer that popped up until you find the GetCardAnimation and then add that into the scene. Now when you move through your timeline you’ll start to see some life in your cutscene!