0:14
Our objectives include creating several keyframe animations for
the targets using the animation editor.
We'll create animations for the Spawn, Idle, and
Exit states of the target by adjusting the scale of the target over time.
0:27
We wanna create an animation on one of the targets, so let me bring one
of the pre-fabs out on the scene so we can see it and we can modify it.
So I'm just gonna go ahead and grab the Target-Positive1, and
drag it out onto the scene.
I want to position it so I can actually see it, so
let me just drag it out there and then we'll modify the position.
So I'm gonna set it at X of zero Y of three and Z of 12.
Okay, so its just right out there in front of our camera.
So with the Target-Positive1 game object selected,
I'm gonna go ahead and open the animation window.
So under window, let me pick Animation,
and of course this brings up the animation window.
And I always like to anchor the animation window to my main interface when I don't
have multiple windows just to make it a little bit easier.
So I'm gonna grab the tab for animation and drag it down here to the game area.
So now I've got two tabs down here, the game and the animation.
You could really bring this anywhere you want,
and perhaps we'll move it around as we play around here a little bit.
So the first thing it says is To begin animating Target-Positive1,
create an Animator and an Animation Clip.
So, let's go ahead and click Create.
1:50
And, this just created two things in our project,
it created the Target Idle animation clip, and the Target-Positive1 animator.
So, I'm gonna go ahead and create a new folder to hold these things, and
I'm gonna call it, Animations.
2:20
So this initial Target Idle animation that we've set
will be the default state of our target during game play.
So I don't actually wanna set anything on the idle, I just wanted to create it so
it basically grabs those default settings that we've already set up on the target.
So now what we're gonna do is we're gonna create another animation clip.
So I can click the drop down here and select Create New Clip.
And I'm gonna call this one Target Spawner.
2:59
So this is gonna be an animation that's gonna play when the target is
first spawned.
So to set this up, first off, make sure that your game object is selected, so
we see it in the Inspector.
So over here in the Animation editor, we're at frame 0, so you can see it here,
or you can see it in the timeline.
3:16
And, when the object first enters the world,
I want it to be, basically invisible.
So, kind of an easy way to do that is to change the scale to 0.
So, let me change the scale from 2 to 0, 0, 0.
You can see that because we're recording, and I made a change,
it shows that change as red, which is kind of a nice feature of the editor.
So you can always see, quickly, the values that have changed in the Inspector.
So let me move out to frame 10 in the timeline, and
let's change the scale again.
3:50
So let me change the scale to 1.3, 1.3, 1.3.
You can see it auto created a key frame in the animation editor,
since we are recording.
Let's move out one more to, let's say frame 25, and
we'll go ahead and set the scale to the regular value of 2, 2, 2.
4:21
And of course, we want this animation only to play once, so
we want to turn off looping.
By default, animation clips have looping on.
So for example, if I click on Target Idle here, you can see that looping is on.
For idle, we actually want to keep it on, because it's just gonna sit there in
the idle state, so we want it to loop over and over and over again.
But for the target spawner, we just want it to play once and then be done.
So let me turn off looping here.
So let's create one last animation that will play when the target is
exiting the scene, based on the target exit script we already attached.
So once again,
let's click on the Target-Positive1 game object, go over to the animation editor,
5:12
And click back on the game object again to set up my animation.
So this is basically gonna be the opposite of the entry into the world.
So let me go back to frame 0 and I want my scale to be the default size of 2,
2, 2 at frame 0, so I'm not actually gonna make a change here.
Let me go to frame 10 and let's modify the scale.
We're gonna actually scale it up a little bit,
because it's going to kind of bloop full, and then out of existence.
So let me change this to 2.1, 2.1, 2.1.
Notice when I did that, it created both a key frame at frame 10 and at frame 0.
So if I scrub back, it goes from 2,
scrubbing forward up to 2.1 in the x, y, and the z location.
And let's go out to frame 25, and then set the x, y, and z scale to 0.
Okay, and then if I play, you can see that it scales up, and then down.
Now we've been looking at the dope sheet, which is the sort of key frame view here.
You could also change to curbs view, which basically shows, if I open up the scale
property here, it shows, sort of visually, what's happening scaling up and then down.
And you can actually drag the key frames here.
And you can right click on key frames to get little control points,
6:42
Okay, and you can do that over each of the X, Y, and Z.
I think I'm working on the Z right here.
I'll go ahead and undo what I just did.
Okay, I'll go back to the dope sheet.
Okay, our animation is basically set up the way we want it, except for, of course,
we want the exit to play just once.
So let me go to that animation and turn off the loop.