Welcome back my fellow game developers
to a brand new video.
And in this one, we've actually added an animation,
which is the layer dashing into the animator.
So when I run the game,
you can see right here that we are moving.
When we press the space,
we don't just move faster.
We actually do the really bully.
What is really bully them?
Something from my childhood.
But anyways, you can see as we walk,
we can also do this.
We have the cool down and nifty thing
is we've added at the last second,
it was off the top of my head when we are shooting.
If I do the torpedo, there you go.
You can see that we can no longer should because
obviously we do not have a gun, our hands.
So let's not waste any more time.
And let's get started.
Okay, so time to animate the torpedo.
Firstly, we are going to do is we are
going to go into the dome player,
select the animations, the idling.
We are going to create a new clip and here which is
going to be set and the animations layer.
And let's just call it dashing because each one of us,
or player dashing to stay consistent with the other name.
So player dashing, save that.
And now let's get started.
Now, we know that we are accessing.
We are changing the animations or the properties on
the body sprite renderer
and scrolling down into the sprites.
So we're going to add this.
Let's open this up so we can see them properly,
just like we were always doing.
So let's see the dashing 1, 2, 3.
And let's actually, I want to
just open this up and properly see what's happening.
So we have 1, 2, 3, 4,
5, 6, 7 sprites.
And we've got all of them properly. Let's see.
Okay, So all of them,
That's called this, the D1, D2,
D3, D4, 5, 6, and 7.
So I just want to avoid
the confusion just so I know which are the d's.
So there you go. 12345 through seven.
Hold down, Shift, select them all, put them here.
And I'm going to remove the first one and I'm going
to move all of these to the start.
And now let's expand this a bit,
but let's make it around.
There we go, run it.
Let's see.
Okay, Very nice. So even
though we still have the arm in here,
if you want, this is
something that I was thinking a lot about.
So the arm and the gon stay in place.
What should we do about that?
Well, honestly, I'm just going to keep it as it is.
You can rotate the arm,
you can vote it began,
you won't be able to shoot.
I think it would be a good mechanic actually.
Maybe we should even add it.
No, because I want to see the arm and
the gun rotating during
this time will not be able to shoot obviously,
but we don't want to change the rotation of the gun.
It will cause a problem.
There we go.
This is the dashing,
but we can do is we can maybe turn off just
as we can create a recording where we turn
off the player's body and arm.
Maybe just hide them for a second.
At the start, we turn them off.
And by the end,
oops, not the body.
I meant the arm and the weapons on.
We turn them off.
And at the end,
when we finish the rotation,
we need to make sure that the,
this is the last one.
Paste it in here. We turn this back on.
Now hopefully this will not cause any errors.
We save that, run the game.
Also. We need to actually trigger this.
Let me just go back.
And should be there is a problem.
So what I believe will happen,
maybe this will cause a slight problem here.
So you can see the weapons on.
We got a reference to it and the far point.
So what I'm afraid of is that when we
turn off the weapons on,
these will no longer be working.
But let's see what happens and waste we save that.
Let's go into the animator and
we'll worry about that in just a bit.
So what should we be doing?
We are going to start dashing
when we are in the player walking.
So I'm going to go from player walking to player dashing.
I'm going to create a triggering here.
And I'm going to call it the dash.
There we go.
The condition in here will be the dash.
Yep, So from walking to dashing, we have this.
And what we can do is we are going to maybe have
an exit time because we don't have
an actual time for when we stopped the dashing.
We don't have a condition that makes us stop bashing.
If we don't go back,
we will keep dashing forever.
And we can also be dashing when we are widening.
So I'm going to move this a bit,
make them look a bit better.
There we go. There we go.
And I'm going to make sure that this is
also under the condition of dashing.
And we are going to remove
any transition time from walking and the dashing.
Let's go ahead and test this out.
Actually, if I go into the animator run the game,
we can see the idle right here.
And it should not have maximized on play the game.
Let's see how this works.
So this is my actual process of I dash.
There we go.
We have it working correctly.
I stopped dashing two. Okay.
So as you can see,
there is something a bit
wrong if I tried to shoot right now,
where are the weapons?
So that we make some kind of mistake on the doom player,
the dashing, and this one is turned off.
Do they get turned on?
Yes, they do. On the last frame,
but for some reason it did not turn on.
So I'm going to run the game
again and see what the problem is.
So I dash o,
okay, now I know the problem we are looping.
So in the animation, layer, dash,
stop looping, this is the first time I forget
so many times to remove the looping in a game.
So let's run this again.
Test this out.
So I do the dash, I stopped dashing.
I look at the doom player.
Yep, there we go.
So look what happens when we dash.
Okay, So that would be dash.
I didn't know 0.
So we are still in the dashing animation.
Great. Now we are going to make a transition
back from the dashing to
the player walking and player idling.
And this one will have an exit time.
We will remove the exit time on the way going back.
So from the dash into the player, idling and walking,
both transitions should not have an exit time,
nor do they need to have a transition duration.
And while going we will have
some kind of exit time right here.
So we will keep the exit time as it is. Why?
Because when you are creating animations and you have
extra time at sort of happens
automatically and perfectly for that moment,
if we have a bit of a longer exit time,
the animation might be
cut in the middle and then back to idling.
So let's test this out.
Anyway. I'm going to go ahead and run the game.
So when I dash,
there we go and we don't go back. Why is that?
We don't go back to the eye,
the link for some reason.
There is something not working properly.
The way this works is when this animation is playing,
then we have an exit time.
So it's not about this one,
the one that's going towards the
dashing for the one coming back.
So this was a mistake on my part.
Something I thought I knew or of course I know this,
but for some reason I'm
mistaken for the way back, not the way going.
But anyways, one thing I noticed,
if we play now the gushing works properly.
So even if we are walking,
we said the trigger,
we have the splitting.
Okay. So while we are working, there we go.
We stop working because we are clicking on this.
We will test this out inside of the game.
But for now, you'll see that when we dash,
we play only have the animation notice
here in the dashing.
So you'll see that we play have
the animation and then we go back. Why is that?
Well, because on the exit time and
here we are playing 60% of it.
So what we'll do is we'll simply increase this until it
becomes around 97 or even one.
And this one also, so this is a percentage.
And when you increase it,
you see in here in the timeline that we play
the entire dashing and then we
go back to the player walking around 97.
I don't like to keep it at one because we will start the,
again the player dashing or have something stale.
So 97 percent run the game.
Now when we dash, there you go.
We do the dash.
We do the dash,
we do the dash and everything is working properly.
Let's test it out when we are walking from the game.
So we're walking, we're walking, we dash.
Okay, it's not being triggered.
Really nice. Why is not being triggered?
Well, because it's part of your challenge.
Your challenge is to trigger the torpedo animation
so you only have one task and that is an update.
When we press the buttons,
make sure to trigger
the animation and you should know which buttons.
Maybe you use something different than space.
That's why I use buttons and always pause
the video right now and go make sure we dash.
Okay, welcome back.
So in here, when we dash,
we are going to go ahead and say that
the player animator set triggers, set trigger.
And because this is a string reference, we go back,
we copy it, we go back in here,
we pasted, we close this off.
And finally, I also want to add
a small comment in here for later on,
we are going to
change or make sure that the player is invincible.
So access the layer health handler
because it will be a separate script.
And make sure he is invincible for a while.
Great, so we're going to save this now,
go back into our game and we are going to run.
So now we can shoot.
We do the dash,
we can shoot, we do the dash.
And if we are dashing,
we are still shooting even though the arm is destroyed.
So there you go.
We can also Dash while we are
walking and it works perfectly fine.
There you go.
You can see that we can
dash while walking and we go back to walking.
Now, the problem here is that when we dash,
we shoot, we can still keep shooting,
even though we are dashing.
Now, it's kind of easy.
We can create some kind of Boolean here.
Make sure if we can dash then we cannot shoot.
This is a good idea actually.
And where is it pointing gun whereas the player shooting?
And we can create a condition.
And here, this is really nice.
I didn't want to do it right now
because later on when we create advanced weapons,
everything that revolves around shooting
mechanics will be moved from the script.
This is where we will explain how we
evolve our scripts as we go on.
But for now, let's just add this little condition.
That's a good way to teach something new.
We're going to check before we start player shooting,
if we can, dash is equal to false. Why is that?
Well, because while we are dashing the can dash spot,
so we have this kind of counter.
And we're going to say in here that return,
if this one, excuse me,
return, simply just that.
So what does return mean?
Return means that we go out from the player shooting.
So this whole code right here does not execute
as soon as the candle is false,
we can no longer shoot.
Let's test this out.
I hope you understand what we mean by return.
Return means that we just get out,
we stop everything on this.
If this condition is not true,
so the dash, the dash is true alone.
This means this entire condition is false.
This means we do not return.
So save that back in our game, from the game.
We should see that when we are dashing, there we go.
We stop shooting until they cool down as finished.
Okay, great.
So this is just a small line
of how we can fix this later on,
of course, this will all change.
So I hope you enjoyed the video.
I hope you made the commitments in here.
I hope you left a review.
If not, this is the perfect time to
do so. Thank you so much.
Stage all made the dashing animation.
Now we're cooler.
Commit the changes, and I'll see you in the next video.