Learn how to import and manipulate animation clips on the Timeline in Unity. In this video, George places a number of animation clips on the Timeline and shows how to manipulate and retime these clips. He then shows how to create animation from still poses using clips.
- [Instructor] Now we're going to create a timeline and add in our animation clips. Now the Timeline in Unity is actually attached to an object. So we can attach it to any one of the objects we have in our scene already. But to make this a little bit easier in terms of a workflow standpoint. I'm just going to create an empty game object and we'll attach the timeline to that. So I'm going to go to my hierarchy window. Just go ahead and right click. Create Empty.
Now this comes in as a game object, but if I click on it, I can rename it. So I'm just going to call it Timeline Object. Now this in itself is just an empty container. It does not have a timeline in it just yet. But if we go into our Timeline window, and I have it here on my interface, we can certainly go into Window Timeline. You'll see that when I select any one of these objects, it's going to ask me to create a timeline for it.
Now this is very similar to what we would do in animation where we would create a clip. So I'm going to select my timeline object and we're going to create a timeline for it. So I'm going to go ahead and select Create and then it's going to ask me where I want to place this. Now I'm just going to place it in the Root Assets folder for now, and we can give it a custom name, but right now the default is Timeline Object timeline. So I'm going to go ahead and click save.
And now we get a timeline. Now the timeline itself at this point really does nothing. So if I scrub it, I really don't get much of anything. But if I want, I can basically assign an object to that timeline. So in this case, I'm going to make that garage door open and close. So let's go ahead and create a new track here. So I'm going to go ahead and do Add Animation Track. And when we do that, it doesn't have anything assigned to it.
So I'm going to just click on this here, and we're going to select the garage door which has those animation clips. I'm going to go ahead and double click on that. So now I have my garage door in my timeline. Once I have this, I can now bring in my animation. Now my animation is in my project window under the animation folder. So you can see that I have garage closing, opening, as well garage close and open.
In order to make this look a little bit easier, I'm actually going to go ahead and click and drag my timeline just kind of out here so I can float it so we can kind of see this a little bit more easily. So let's go ahead and just select my garage opening and just drag it onto that timeline. And now when I do that, I can now scrub and that garage will open. So now I can also select garage close.
And again just drag that to the timeline. So now my garage door opens and ah-oh, it snaps, and then it snaps open again and closes. So one of the things we can do is we can just butt these two up together and so now I've got the door opening and closing very easily. So if I want to, I can just press play here and we can see how that works in real time. Now if I want to make this open a little bit more quickly or slowly, I can certainly work with this.
So I'm going to go ahead and select my garage closing here and let's delete this. And let's just work with open for now. Now if I want to, I can right click on this. We have a speed setting. We can double or half the speed. So if I double the speed, you can see that it's going to open a lot faster. Or if I half the speed, that brings it to normal, but if I do that again, it stretches it.
So now this is only opening along about four seconds. Now I'm going to go ahead and take my speed and double it and that should put it back to normal. Now another thing you can do is you can click and drag the duration. Now what this does is it basically just kind of lops off the end of the clip. So you can see that here we're not getting fully open. We have to drag this all the way out in order to get that to open.
So if I drag this shorter, I'm going to lose animation. Now that may be a good thing if that's what you want. I'm going to go ahead and drag this until it snaps and so now I should have a full animation. Now if I want to I can also drag beyond this and what happens there is that it just repeats. And so that's not really what we want. So we kind of want to keep this as a whole unit here.
Now another way to edit this is to position your timeline here and we can right click over this and then we can do an editing so we can trim the end to that position in the timeline, and again that will just cut it. Now again I can just drag this if I want to and I find that a lot easier. So under Editing we can Trim Start, Trim End, you can also reset the editing and that's what I'm going to do here. Now there will be a time where we'll want to open the door and keep it open for a while.
That's one of the reasons why I created the animation or the animation clip with the door open. So I'm going to go ahead and select garage open and just go ahead and drag that in. So now, it just stays open. And if I want to, I can maybe double the size of this. We can go Speed, Half speed, and that will go ahead and lengthen it. And then again we can drag in the closing here and now I've got the garage door opening, holding still for awhile, and then closing.
Now another way to do this is to not even worry about the animation. So I'm going to go ahead and select garage opening and garage closing and now all we have is this clip with the garage opened. So now my garage is nothing but open and I can go ahead and drag in that other clip we created which was garage CLOSE in capital letters.
And now that we have GarageCLOSED, I can actually, if I want to I can butt these up against one another and you can see I can snap that open. But that's not really what I want. I want this to fade into that. So I'm going to go ahead and select this. Again right click over it, speed. We're going to go ahead and do Half Speed, lengthen that up a bit. And now if I drag this Open clip over Closed, you can see that now I can control the speed of this.
So if I want this to be shorter, I make that transition shorter. I want it to be longer, I make the transition longer. And so now with just two stationary clips, I can actually get animation. So those are some of the ways to work with clips in Unity. So go ahead and play with this. It's really actually kind of fun. It's a lot like a non-linear editor and it really is very easy to use.
- Creating animation clips with Timeline
- Recording animation
- Setting up Cinemachine cameras
- Adding animation to cameras
- Switching cameras
- Adding effects and transitions