Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
In the last episode, we implemented the slide, but there are still a couple of issues and things we
want to polish up.
I can shoot while sliding, which is something I don't want.
I can turn around while sliding.
The momentum doesn't change, but the animation turns around.
The sprite direction turns around.
I want to be able to cancel the slide into a jump.
Well, now we can just kind of jump while we're sliding, but I actually want to cancel the slide if
we jump.
And I also want to cancel the slide if we go off a ledge.
And I also want to cancel the slide if we walk in the opposite direction.
And lastly, I also want to prevent sliding while we are in the air because now we can kind of do this
air dash into the slide, which is kind of fun.
But um, yeah, I want to prevent this to show you how to prevent this.
If you like this, you can just put it back in later.
First off, let's prevent shooting while sliding.
And this is very easy.
So in the BP player I'll just turn off the play mode and we just look for our IA shoot.
Uh, here.
I should go here.
And now we don't just want to check for instant, but we also want to check for is sliding.
Is ground sliding not boolean.
Like this.
And both of these need to be true.
So we are not sliding and we are not stunned.
So yeah add an and boolean here.
Just like this.
And then we also want to do the same for the charge.
Uh, charge shot.
Right.
So here also like open up some space and here we can just delete this and just copy this instead.
Copy paste Ctrl c, Ctrl v.
And use this here and create some space here for the.
These ones.
And you can actually use the arrow keys.
If you select this, just use the arrow keys on the keyboard to move them around.
And this is all we need to make sure that we cannot shoot the regular shot.
And we also cannot shoot the charge shot while we're sliding.
Let's try this out.
Right.
I try to shoot, I can't, I charge a shot.
I let go while I'm sliding.
And also I can shoot.
So this solved the first issue we had.
Next up, let's fix the sprite turning around if we steer against the sliding.
And this is also a very simple solution.
So in the BP player under the move event the IA move right here we have the update rotation.
And here we already added this condition for if we press up and down that nothing happens.
And here we just want to add another condition.
So it is not the up and down input.
And another and Boolean.
And rule in here.
And we are not sliding.
So again get is ground sliding and not boolean.
Not building like this and connect all of this.
Open up some space.
Right.
So now if we are sliding or if we're just pressing up or down, we aren't just we are just not going
to execute our update rotation logic.
So try this again.
Slide and try to steer against it.
And you cannot change the sprite direction right.
Everything else still works the same.
Second problem fixed.
Next problem being able to slide while in the air or doing this kind of air dash.
And for this we can just go to the player and again look for our IA jump, because this is our jump
input.
And what do we do here.
Well we check for is holding down but this is not enough.
We also want to check for is grounded.
So we can just add a another branch before this.
Because actually the jump should also not happen if we're not grounded.
So we can just select all of this.
And move it over to the right.
Like this.
Yes.
And then have a another branch here where you can just go here from falls and branch.
And we can look for.
The, um, is moving on ground, uh, node.
So from the character movement we can just get is moving on ground.
And this basically just tells us are we grounded or not.
So if we are grounded, then we just continue doing our jump or doing our sliding.
All of this is fine.
And if we are not grounded, well, we just don't want to do anything.
We don't want to do anything because the wall jump actually happens on the left side already.
So for this one we don't have the ground check.
So this is fine right.
So let's try this out I can jump.
Jumping works fine.
Sliding works fine.
Wall jumping also still works, but we can now not do the slide while we're in the air.
So we also fixed this problem.
But again I think it's actually a a bug.
That was kind of a fun gameplay mechanic.
So if you like it you could just put it back in later.
Next up, I want to be able to cancel the slide when jumping right.
So now we can kind of jump while sliding, but we just keep on sliding.
And it's kind of awkward.
We just want to completely stop the slide if we press the jump button while sliding.
And again, in the BP player, we are already in a right position right here.
For the Aya jump, we have the uh, here the root motion constant force with callback.
And we can simply use the async action.
And here we call cancel.
Cans like this and it and it automatically connects it to this.
Which is weird because then after it executes it, it's just going to cancel it right away.
So hold alt and click here.
We actually want to call the cancel from jump so we can just connect right here.
This doesn't look nice, but I just want to show you that this actually works.
So we can just do this.
And it cancels the slide.
The animation is still playing, which is another issue, but a functionally it works.
So here after we cancel, we also just want to copy paste this and just um, set this ground slider
to false.
And now let's have a look at this.
Right.
I can cancel the slide now into jumping.
And again this is just very good for precise platforming to give the player control.
Because now we can do actions like this right.
You can slide jump shoot.
And it just makes the game feel very snappy and responsive.
And even this canceling now worked.
It is actually not nice to just connect the node from jumping all the way up here.
And there's also going to be other places where we want to cancel the slide, for example, if we take
damage.
So an easy way to just create shortcuts to this cancel is to just here right click Custom Event and
called Cancel Slide like this.
And we just connect here and disconnect this one.
Hold alt left click.
And now this is a custom event.
We can just call it here from the jump.
And here we can just call Cancel slide.
Right.
So it's going to basically shortcut us to this event and call the cancel.
And just to show you that this still works we can do this.
Like this.
One problem with this, though, is if I try to only jump, I'm not going to slide.
I'm only going to jump and I exit out, press escape.
We get an error message.
And this is because.
Even if we don't have an active instance of this, uh, root motion, constant forces, we still try
to call an async action cancel on something that doesn't exist, because this only exists after we call
the slide.
But here we simply call cancel slide from the jumping without having ever called the slide before.
Right.
So this is null.
So we need to add an is valid.
Check here.
The bottom one with the question mark right is valid.
And again it connects it here.
We don't want to connect it here.
We want to connect it to the cancel slide here right like this.
And only if this is valid then we actually want to go through with the canceling and just rearrange
these nodes.
Here I want to double click here create a reroute node like this.
And now we can also just reuse this one here.
This is fine.
This and create some space.
And yes.
So now this is just again a safety net.
So if I do it now and I try to just jump, I'm not going to slide.
Just jump.
We actually don't get an error message.
And if I slide and jump, it works.
So this prevents us from calling this sorry, calling this cancel on a not available async action.
And now that we prepared an easy way for us to call the cancel slide, we actually want to cancel it
when we take damage.
Because now if we go up here and we slide into the crab, we actually get knocked forward because the
slide is still active.
We actually don't get knocked back.
So let's do that.
Now in the BP player, we just want to look for any damage.
We can just right click any damage.
And if it already exists it's just going to teleport us there.
And now here for the any damage event we have all of our well the was set during charge, the trigger
invincibility and we have our entire knockback logic.
But let's just collapse the knockback logic for now because it's a very large and it's kind of hard
to understand what's happening here.
Just select all of this all the way up here, not the trigger invincibility.
Hold control and get these two nodes as well.
Right.
So everything that is related to the knockback and we can just right click collapse nodes.
We cannot collapse the function because we have delays in here and just call it knockback.
Actually, I think I just did two comments.
And this is a problem if the node is outside of the screen, if you try to rename it, it often doesn't
really work.
So knockback.
And just drag this over to the left side.
And here we can double click.
Do it like this.
And self is a little bit weird here.
So actually you want to rename the self to damage causer like this.
And here.
And yeah, compound save, no errors.
Everything here still works.
It's just a little bit easier to understand what's happening here now.
Any damage to find this again.
Right.
So before we do the knockback very important we want to cancel this light before we do the knockback.
Because if we try to cancel it after they're kind of still fighting against each other.
So actually this is the first thing we can do.
So before trigger invincibility, charge and everything.
Let's just cancel the slide first.
So here after any damage from the parent we can just cancel the slide.
Now we can just compile and save this and go here.
Right.
This still works.
This is fine.
And I get hit and it is fine.
The slide is being cancelled.
We get knocked back properly, we get the invincibility.
And even from the right side, right.
I jump in here, I get knocked back properly.
This is working fine now, but we still have a couple of things left.
Right.
The next thing we want to do is to.
Let's just shoot this guy to cancel the slide when going off a ledge, because now we just keep on sliding,
which would be fine, which you could do if you want that in your game.
But again, we want to kind of mimic the Megaman genre of games.
So there it's customary to just cancel the slide when going off a ledge.
And here we have in the BP player an override which we can use.
So for the functions there's overrides and we have the on walking off ledge override, we can just click
it.
And this is something that's available on the character that is being checked for.
And we can just hook into it and make use of it.
And this is super simple.
We can just drag off here.
Cancel slide.
We don't care about the vectors and float that we get here.
We simply want to just look for the event and cancel the slide.
Very easy right?
Compile and save.
Go in here, try the same thing again.
And a slide and the slide stops.
Once we're off the ledge.
Right.
Perfect.
The next thing you want to do is to cancel the slide.
If we slide to the left for example.
But hold right.
So these Mega man type of games usually allow you to cancel the slide if you just press in the opposite
direction.
And this is also kind of easy to implement.
To do this, we can actually reuse something we created before with the drywall slide.
Right in here we have the is holding towards the wall and we can just copy all of this, get all of
these things.
Control C to copy we go to the event graph.
We go to tick right event tick.
If you can't find it just right tick and it's going to take you to it.
And after the drywall slide we can just paste this in control V.
And we actually want to just change one thing.
And here we just have to check this one thing.
We don't want to check for bigger than zero, but actually check for smaller than zero.
Because the result we get here is if the direction we move in matches the direction we are inputting,
we are getting a value bigger than zero.
And if they don't match, we get a value smaller than zero, and if they don't match, we actually want
to cancel the slide.
So we can just go here and here you have a branch.
And here cancel slide and we have to check on tick.
But actually we don't have to always check.
We only have to check for this if we are sliding right.
So here we can get is sliding is ground sliding and have an and boolean.
Like this.
So if we are sliding and this is the case, then, uh, here, then we want to cancel the slide.
And there's a nice thing with the and operators like this.
If the first one is false, it will actually shortcut.
And it's not even going to evaluate this one.
And we're already going to shortcut to false.
So we're not going to waste any resources on checking this if we aren't ground sliding.
Right.
But if this is true then it's going to check.
Is this one also true?
And only if they're both true.
Then we are going to cancel the slide.
And this is not an Unreal Engine thing.
This is just a general programming thing that optimizes and booleans or booleans.
And of course, now we just want to collapse this.
And here we can just select all of this.
And here we don't have any delays, so we can also collapse the nodes, but we can also collapse the
function.
And it's called try cancel slide.
And move it over to the side and look into it.
Right.
So we just have encapsulated this nice little function and let's try it out.
So I'm going to slide.
And while I slide I'm going to press the opposite direction.
If I press the same direction nothing happens.
If I press the opposite I can just kind of cancel the slide.
And again this is good for precision platforming, right?
Because I could like slide towards a ledge and then just, oh, I don't want to go over the ledge.
And I just kind of, uh, hold in the opposite direction.
And this is just a nice little thing for precision platformer games.
And now there's only one last thing we want to take care of.
And this is if we press slide multiple times, it actually kind of bugs out because we slide again while
we are still sliding.
We actually want to make sure that we can only slide if we aren't already sliding.
So this is another small branch condition we have to input.
So in the BP player again we want to look for our IA jump.
And here we have the Is wall sliding.
We have the IA move.
And here we try to actually jump right a slide.
Sorry.
Here is our actual slide logic.
And we can just put this over here and just add a branch here.
Branch.
And we get the is ground sliding, not boolean.
And put this in here.
Like this.
And just open up some more space.
It.
Q here to align them.
Right?
So now we can only slide if we aren't already sliding.
And again this is a very common pattern, right.
You check if you can do something then you set that you are doing it.
And then after the action is over you allow doing it again.
This is kind of like a cool down in a sense.
And we can just compile and save.
Go to the map.
I'll try to just hammer sliding, but now we don't get this weird bug where you can just slide multiple
times.
We can only slide if the slide is over now.
Just like this.
And this lesson was a lot to take in.
But this is real game development, right?
You're gonna implement a new feature, the feature itself.
It feels kind of easy to implement.
And then you start noticing that there's so many edge cases you have to handle that maybe it starts
fighting with some of your old systems, and you have to make sure that it works together in harmony
with all of your other systems.
And so even if this lesson might have been a little bit annoying, a little bit confusing, this is
real game development.
And you're going to face problems like this all the time.
But congratulations.
This is a huge step.
The slide ability is kind of complicated, and all of the edge cases we took care of are also a good
learning experience.
And in the next lesson we're going to talk about respawning the player if it is defeated.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.