Welcome back, my fellow game developers.
In this video, when we run our game,
our hand and gun are no longer static.
And when we move left and right,
maybe it's not very noticeable,
but you can see that the arm that be just make the movement speed a lot slower.
So now when we move, there you go.
You can see that the gun moves up and down and the arm moves left and right.
All actually rotates a little bit.
How cool is that?
Now we are no longer just a gun pointing monster killing, doom Slayer.
We are actually an animated dooms layer that does of the other things.
So let's not waste any more time and let's get started.
O k.
So what do I mean by enhancing our animation?
Don't we already have a good enough animation? Well, no.
As you can see, when we play the animation,
the gun doesn't move,
the arm doesn't move,
and that's not good.
So let's fix this.
Let's go ahead and start with the eye-opening.
Are going to watch how I do it,
and then you are going to implement it on the walking.
This will be your challenge.
So even I like to keep the challenges a surprise,
but I want you to focus on what we're doing.
So we have this little red button right here.
When we click it, we start recording.
You can see that we have the rat and we can change anything that we want.
So during this animation,
I can increase the movement speed.
So you'll notice that when we start at the beginning,
look on the movement speed as I move on the timeline,
you'll see that it increases to the point that I've said it.
And then for example,
I want to decrease it.
And you'll notice that we have this additional property being added.
So we start off with them.
We move up to 72 and then we move down to minus four.
So we started going backwards.
How cool is that?
But we're not here to change the movement speed.
We can change anything we want.
By the way, this,
this is why animations,
such an amazing and powerful tool in Unity.
What we want to do is we want to move the arm and the arm will open up and down.
So what we'll do is we are going to,
this is our first animation.
Let me just make the arm a little bit
bigger because I want to cover the whole side of the player.
I don't want anything to be visible behind it,
so I'm going to choose the arm and I'll just make it around 30.
Apply that. So now the arm is a bit bigger.
It covers the arm of the player.
And back in here.
Oh, did I changed?
Was this during the animation Aquino?
So when we go down,
you can see that we move down a little bit.
I'm going to move down the arm and the weapon.
Just a little bit.
Okay. And then when we move down even more,
I'm going to move the arm and weapon a little bit more.
And then when we stand back up,
I'm going to copy the original position of the R and gun,
copy that and paste it at the end.
Okay, great. When we finish recording,
we need to make sure that we had this red timeline.
Make sure that we stop recording.
So now we have the animation set.
You can see right here we have two additional properties where we change the y,
the x, only the position of the transport.
We could have done this by adding a property and accessing everything from here,
but this is a bit fast.
So let's see what we have in here.
Let me close those off.
What happens now when we play the animation?
There we go. You can see that the arm and the gun are going up and down.
But it's obvious to me and you that there is something a bit wrong.
What's wrong? You can see that the player,
let me just stop that.
I'll play this.
The arm starts going down before the sprite actually triggers,
before the first small dip NT player.
And there you go.
You can see that the arm is faster, not faster.
But the problem is when it comes to animating sprites,
we have these four images, okay?
So we, we have the first image.
We weighed these 10 frames,
then we have the second image.
We went ten frames,
then we have the third image.
But the arm and other animations work differently.
If I look, for example,
on the weapons are, notice how the y changes.
It doesn't go immediately to minus 0.332.
It actually slowly goes from minus 28.
And every single frame it goes less,
less, less, less, less until it gets to this point.
And then it goes down a bit less,
and then it goes down a bit more. Oil goes up.
Original position. That's not what we want.
It looks very bad.
If I run the game,
you can see that it looks very bad.
It looks as if the arm is not properly attached to the player.
Now, if you want,
if it's part of your game,
If that's the quirk you want to have in your game, then go for it.
I recommend you play around and create your own animation.
You don't have to follow my exact steps,
but I want to show you what can be done.
You have right here the dope sheet. Dope sheet.
I'm not sure how it's pronounced,
but this is where we set the various properties.
We can do also something else,
which are the curves.
And you can see right now that we have these very different curves.
So we can change the way the sprites,
the weapons are in position and how do you arms position change with time.
So for example, I can select the x in here.
The why, how a changes and the z.
Let me just give you an example so you understand we have this lever right here.
When I click on the second frame,
you can see that I can adjust how fast
or slow or how the curvature of the animation goes.
So if I created like this or make it like this,
you'll notice that the y will increase over
and then go down and then go lower than intended and then get to the goal.
So when I play it, look up what that looks like.
You can see, there we go.
So let me slow this down.
So the y goes up and then it goes
down and then it goes to the position that we have intended it to be at.
What is the point of doing this?
We can play around with these,
make them as we want.
But what we want is we want to take this and
take it all the way until it becomes a small square.
How does that look? Let me show you.
Now when we play.
There you go.
It's not very noticeable.
But again, when we move,
you'll notice the gun doesn't move down only the arm.
And when we get to this point,
the gun falls down with the player and then goes up slowly.
So we have figured out a way to make this transition just like the sprites.
So again, we take this one also.
There we go. So now you'll notice the gun moves up and down.
Was the player exactly.
Let's do the same for the arm.
If we click on the why.
He said that in here.
Let's run. You can see how the arm works.
We'll choose the second frame.
We'll move it all the way.
We'll choose the frame also will move it all the way.
And now the animation should look perfect when we review it.
There you go. You can see that the arm, the gun,
and the player sprite all move together in unison.
So I hope you understood what we are creating in here.
Let me run the game so we can see properly what's happening.
There you go. You can see that now the R and D can look really part of the player.
Now, before I issue the challenge,
there is one thing that we need to take care of,
not actually take care of or take caution of while we're playing.
You notice you've created me and do together.
We've created the gun having a rotation.
So we rotate the gun around to point towards our mass.
If we try to add rotation to the gun right now as we are walking,
or if we tried to add rotation on this animation,
the pointing of the gum will not work anymore.
Why? Because update and animation will be in conflict.
So the animation wants to rotate the gun one
way while the mouse wants to rotate the gone the other way.
And what happens is the animation wins and we can no longer point are gone.
So with that said,
now that you know that we should not add rotation to the gun,
but feel free to add rotation to the arm.
And now it's time for your challenge.
Your challenge is to finish the walking animation.
So swing the arm around while walking so you can change the rotation of the arm,
make sure it covers the real arm of the player so we don't have any inconsistencies.
Make sure you do not rotate the gun in the animation if you want,
Be my guest, try it out,
see if I was lying or not.
Maybe I was who knows.
So pause the video right now.
I swear I wasn't. I never do.
And do the challenge.
O K.
Welcome back. So I'm going to go from either turning to walking.
And I'm going to do the same.
I'm going to click on the Record button.
And let's see, I'm going to,
this is the first frame we are already walking.
So what should we do in here?
You can be creative, do whatever we want.
I'm going to do my thing and explains them by step
if you haven't already understood what we did before.
So the weapons on never rotating,
we are going to move a,
let's say up a bit.
So yeah, that's around what I want.
And the arm, I'm going to rotate it a bit and change its position to the right.
Okay.
Then we move to this position.
I'm going to take the gun down and I'm going
to move the arm a little bit like that and change its position.
Let's see, where is it?
Okay, so right about here.
Then we move again,
the gun up and
the arm pose like this,
and goes down a little bit or change the rotation.
And this is all dependent on your preference.
Maybe we should also make the RNA but bigger right now.
Then we move to the next frame.
The gun moves down a bit.
And the arm moves that.
Whereas the arm should the RMB.
Okay, so light around that and moves up.
And finally, we have the last frame where we will copy these three.
So you can see each one of these squares,
the inverted or inverted squares are representing the arm position,
the arm rotation and the arm weapons aren't position.
So I'm going to select all three,
copy them and paste them on the last frame.
So let's see how that looks.
Okay.
So the gun is moving up and down,
which is kind of cool.
Arm is going forward and backwards.
There is one frame that I don't like too much,
which is right here.
And it's because the arm is a bit small.
So I think the sprite actually makes the arm a bit bigger.
We'll change that in a bit.
We can actually even change the scale.
Let's try to do that.
So we're link Chris, oh, no,
not that much will increase the scale to 1.2,
maybe on the X and the Y.
And okay, that's too big.
Let's make it 1.1 and reduce the rotation a little bit.
So now you'll see and it stays the same.
So I'm going to see also the kale keeps increasing in hearing.
Know what, let's not play with the scale.
Let's just deleted.
It's not good to,
causes us able to from animals will just increase it from here.
So if we go into the arm,
Let's make this maybe a bit more.
28, maybe 29.
Apply.
Yeah, I think that's good enough.
And I'm going to stop the animation.
Now. I'm going to go into the curves.
Let's see what we have in here.
We have the gun.
Now what I think I maybe want to keep
the gun the same and let's see what's changing in here.
So the position on the Y and the X.
So I'm going to set these to be,
choose this one, move it up so you can see
right now a visual representation of what we mean.
So we still have the same position all the time.
Until click we go down, click we go down.
And I'm going to change this one.
Also.
Click on the position x visit whereas the curve.
Whereas the curve, okay, So it's down here.
Why do you want to make my life harder?
We rotate this row,
this row, this, and there we go.
Last one stays the same.
So now let's see.
Okay, kind of good.
The position that's adjust the rotation.
So while we are moving,
the rotation around, z is changing.
Okay, What, what's the matter with that?
Let's see.
So for some reason the scales have changed, but no worries.
We will find a solution and then we will move.
Oh, so we can increase this.
Okay, great. And there we go.
So now let's look at that.
Okay, So the arm looks good enough and the gun is moving up and down.
And if we try to run our game,
Let's see how that looks.
Okay, The Eagle is good.
The walking the gun is a bit still fussing around.
I don't like the way it's moving up and down.
Let's change that. And the animation,
close those two things.
Go to the walking position, curves.
What's changing? Okay, It's the y position.
Where is it?
Okay, So we're going to make this square, this one also.
And the last one,
save that, lay around the animation.
Okay, so there we go.
We have the gun moving up and down.
Honestly, it's not perfect,
but it's good enough.
Let's test out the rotation.
If it's working, I hope you test it out yourself.
So now as we walk, there we go.
We are pointing properly.
We walk the gun moves up and down.
We walk with our hand.
We no longer have a static hand and a static gun.
We actually have the player walking around.
How cool is that?
We have amazing animations.
In the final video,
we are going to be adjusting
the players velocity because maybe you haven't noticed, maybe you did.
But when we walked to the right,
we have a certain speed.
When we walk up, we have the same speed,
but if we tried to walk down and left,
you can see that we are a bit faster.
So you can see right now that if we're walking,
then we try walking up.
You'll notice that we are a bit faster and I'm going to
explain why that is how velocity works.
A bit of mathematics on how vectors and normalizing works.
So math, he Yay,
can't wait for the next video, right?
I'll see you then make sure to commit all of your changes.
Look how far we've come.
Look at everything that we've done so far.
We've created, learn sorting layers, created scripts.
Now the player moves.
Now our player moves around using a brand new rigid body and collider.
We made a gunpoint in the angle.
We made the player point in the right direction.
We've added animations.
Now we've enhanced our animations,
will also enhance our velocity,
and I'll see you in the next video.