- In this video we'll have a look
at the new timeline editor in Unity 2017.
We'll have a look at how you can add
and combine different types of tracks
to create cut scenes and cool events.
Also special thanks to
Youdaman and Hans Hoftun
for their support on Patreon.
So let's get into it.
So here we have a simple scene
that consists of four vehicles,
a hangar environment,
and of course a camera.
The vehicles are from Dev
Assets and I will of course have
a link for them in the description.
Now to open up timeline we go window
and select the timeline editor.
I'm just going to dock this
down by the animation panel.
And the first thing that
we're going to do is create
an empty game object where
our timeline data can sit.
Let's go to the Hierarchy
go right click create empty,
let's reset the transform on this.
Let's rename it to timeline.
And you can see now that inside
of the timeline window it says
to begin a new timeline create
a director component and a timeline asset.
Now it can do this for us
if we simply hit create.
First we get to name our timeline asset.
This is also what we
refer to as a playable,
and we can just call this our cut scene.
Let's then hit Save.
And you can see now that
the cut scene appears
in the project.
You will also see that
it's added two components
to our timeline.
The first one is a playable director.
And this references our
cut scene playable object.
Here we can adjust stuff
like whether or not we wanted
to play when we start the game,
and whether or not we want
it to loop once it's done.
It also created an animator component.
And this is actually not
something that we need.
This is just because timeline assumes
that the object that you
create the timeline on is going
to be animated as well.
And you can see down here
in our timeline window,
we now have a timeline
that we can scrub through
and we have a single track.
This track refers to the
timeline object itself.
So we can actually just delete this
because we don't want to be
animating a timeline object.
And we can actually go and select that
and remove the animator as well.
So now we have no tracks in our timeline.
Let's go ahead and add a new one.
And here we have a bunch of
different ones to choose from.
We're going to be creating
an animation track.
This is probably the most common
track and it's what we use
whenever we want to play
animation in our game.
Now I don't have any animation done yet.
So I simply want to take the
object that I want to animate,
which is the big T 90 in the center here,
and drag it into this slot.
It's then going to prompt
me to create an animator
on this T 90 which I'll
just go ahead and do.
Now I can simply hit the record button
and I can then start key-framing
different parts of my T 90.
I'm going to find the turret pivot,
find a good start rotation,
go forward a bit on the timeline.
And right now this is displayed in frames.
We can change this by going to the cog
and selecting seconds instead.
I think three seconds sounds about right,
I can then rotate it over and it's going
to insert a keyframe
and we can now see that
this is animating over time.
I also want to animate my gun pivot.
So I'm going to go back a few frames,
set the starting keyframe here,
about there seems right,
go forward a little bit and
I'm going to animate this up.
So now we can stop recording,
go back and hit play.
And we can see our animation playing.
If you then want to go back
and edit your animation,
we can click the curves here
to edit the individual curves
or we can simply double click
on the track to be taken to
the animation window.
Here we can make our adjustments
and as soon as we go back to timeline,
we can see the changes.
But right now we're only
animating one object.
And the strength of timeline is
the ability to mix together
multiple animations.
So let's go and add another one.
This time let's reference
our Humvee over here.
Let's drag him in and
create an animator on him.
Again let's hit record.
I'm going to select the Humvee,
set a start position,
move forward in time a bit
and animate him forward.
So now as we scrub through,
we can see our two
animations playing together.
Let's stop recording
and right now we can see and adjust all
of the individual keyframes.
But if we have a lot of objects in here
this quickly becomes very hard to manage.
And we can't really
adjust the timing between
these two clips without going in
and editing the keyframes.
So let's first right
click on our T 90 track
and hit convert to clip track.
This is going to take all of
our keyframes and turn them
into one single clip that
we can easily manage.
We can select this clip and
rename it to say T 90 aim.
And let's also do the
same thing for our Humvee.
So let's right click,
go convert to clip track
and let's name this Humvee drive.
And now we can mix these together
in any way that we want.
We can change the timing
or we can even adjust
the length of this clip.
If we now hit play we can see
that our T 90 starts aiming long
before our Humvee starts driving.
But after our T 90 finishes it's aim,
it simply freezes.
If we click on the T 90 clip,
we can change this by going
under post extrapolate.
This means what happens to the animation
after it's done playing.
And right now it's just set to hold.
So whatever the end frame,
it will just hold that into infinity.
But let's try and change this
to something like ping pong.
This means as soon as the
animation reaches its end,
it will play back in reverse.
So if we now play our
sequence we should see
that the T 90 keeps animating.
And indeed it does.
Of course we want to stay
organized in our timeline.
Let's go add to create a track group.
Here we can group
together multiple tracks.
Let's rename this to vehicles.
And let's drag in both our tracks.
Now the next type of track that we want
to look at is the activation track.
This allows us to simply enable
or disable a game object.
It's really that simple.
And in the scene here,
I actually have two cameras.
I have a camera that focuses on the T 90
and I have a camera that
focuses on the Humvee.
So in our timeline we can
use the activation track
to switch between them.
We want to start with
the camera on the T 90.
We can then add another activation track
and here we can reference
the camera on a Humvee.
So in the beginning,
we only want the camera
on the T 90 to be active.
So let's drag out the
camera on our Humvee.
And then after a little
while we can switch over
to the Humvee camera.
So if we now open up our vehicles group,
we can see that we switch
the camera right before
the Humvee starts driving.
And then as it exits the frame,
we can go back to our original camera.
To do that we select the clip,
hit Control D or Command
D if you're on the Mac
to duplicate and simply drag it over.
And we can also extend the lifetime here
to the end of our timeline.
So now if we played this back,
we should see that we
have some nice switching
between the cameras.
And it's actually starting
to look like a cut scene.
Let's again go ahead and add a track group
for our new camera controls.
Let's drag both our
camera tracks in there.
You can of course also
add pre-made animation
to our timeline.
So if you want your character
to play some animation,
we could simply add an animation track.
You would then link the character
and then you can simply
drag in animation clips
to add them together.
So it basically works
in the exact same way
that it did with our vehicles.
And I think this is probably
the best part about timeline is
that you can basically
drag in anything you'd like
and it's just going to play it.
A good example of this is sound.
So if we go onto our sounds folder,
I have two sounds here.
I have some ambience
and I have an engine start.
(motor roaring)
We can simply take our ambience
and drag it into timeline.
It's going to automatically
create an audio track for us
and we can simply make
the clip a bit shorter.
A really cool thing is to focus on a clip,
you can simply select it and hit F
just like you would in the scene view.
So let's now trim this to
fill out the entire sequence
and I also want to add the engine start.
Now this has a bit of room before
the engine actually starts.
If we go in here we can actually see
that it's around two seconds.
Let's take our engine start,
drag it into timeline.
Let's trim it for about two seconds.
Let's then open up our vehicle
so we can see when our
Humvee starts driving.
Let's start the engine
just a tad before that.
Now if you hit play your
sound won't preview.
Unfortunately you still
have to play the game
in order to hear your sound working.
So let's press play to try it out.
We definitely hear the ambience.
(motor roaring)
And maybe we are a bit too
late on the engine sound.
To fix that,
we'll simply drag the clip
a tiny bit to the left.
Let's again try and hit play.
(motor roaring)
And this time it works beautifully.
Finally, let's make sure
to trim our engine start sound to
the timeline length as well.
And just to clean everything up we can add
a track group for all of our audio.
(motor roaring)
So that should be it for our
preview of the timeline editor.
Awesome!
So of course timeline is still very new.
And I'm definitely excited to see
where they'll take it from here.
But I think the tool's
already a great starting point
for creating cut scenes
and in-game events.
And now that we have
timeline I definitely hope
to see more short films made with Unity.
So if you make something
cool using the timeline,
definitely make sure to send
it to me at BrackeysTweet
over on Twitter.
On that thanks for watching
and I will see you in the next video.
Thanks to all of the
awesome Patreon supporters
who donated in September.
And especially thanks
to Youdaman and Hans Hoftun,
Zied Jebali, SupermanTheGr8,
James P., Jesper Mikkelsen,
Thomas Varli, Cyborgmummy,
Jason Lotito, Derek Heemskerk,
Faisal Marafie, Nick Lanng,
Hussam Kazah, Aaron,
Robert Bund, and Peter Locke.
If your name is not on
the list I'll make sure
to include you later this month
and the next month as well.
