All language subtitles for 005 Player Knockback and Stun[UdemyIran.Com]

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

Now that the damage and invincibility is working, we want to add a little bit of knockback if the player

takes damage.

A very easy way of doing this is to go to the BP player.

And here in the any damage event, after we trigger the invincibility, we can simply use the launch

character node.

And here you can specify a vector which we want to be launched into.

And if we just want to test it with going upward we can just put in 2000.

And this is just going to shoot us straight up if we take any damage.

So I can just test this out.

And yeah, you can see we just get flung in the air.

And this is a very easy way of implementing damage.

But we don't just want to go upward.

We also want to be knocked to the left if the character is on the right side, and if the enemy is on

the left side, we want to be knocked to the right direction as well.

So let's try doing this.

The first thing we need to do is detect if the enemy is on a right or left side.

So in here, before we call the launch character, I want to use the look at rotation node find look

at rotation.

And this is a very handy node that we can give a start position and a target position.

In this case the start position is our character our player.

So we can just get actor location.

And it's gonna look into a certain direction, and the target is going to be the projectile or the enemy

that applied damage to us.

So the damage causer.

However, for this to work properly, we need to make sure that the apply damage event is properly being

passed.

A damage causer and what we are doing here in the player is when we begin overlap, like we are checking

if we are hitting an enemy, right and we apply damage to ourselves.

So we need to actually pass the damage causer in here as the enemy.

So right here we check which enemy are we overlapping with.

So this enemy should be the damage causer.

So we just need to connect this here.

Go like this.

And yeah, if you don't know where this is, this is the on component began overlap event on the capsule

component where we apply damage to ourselves and just double click to create some reroute nodes.

And now if we do this, the damage causer is going to be properly passed through here.

And now we can just get actor location.

Of the damage caused, and this gives us a proper look at rotation from ourselves to whoever.

Caused the damage to us.

And this should also work with projectiles and everything.

So if we get hit by a projectile that is on the right side, it can also knock us to the left side.

And the rotation we get here is actually kind of hard to use.

We don't really want to use the rotation, we only care about the forward vector so we can get forward

vector.

And this gives us a directional vector.

And this makes it very easy to tell if we are looking to the right or to the left in order to find who

caused damage to us, and we can just print string here.

Like this and print the vector out.

And let's try this out now.

I'm on the left side.

I walk into the crab and you can see the X is positive.

It said 0.98, right?

It's positive.

We don't really care about the Y and the Z here.

And if I go on the other side you can see that it is negative.

It is -0.9.

Right.

And here it is plus right.

So we just care about the plus and the minus.

Again we don't really care about the value here.

And we only care about the x.

So we can get rid of the printstring.

Now we can split the vector split the struct pin.

And we only care about the x.

And well what do we have to check for.

So we want to throw away this 0.98 and make it a round plus one or a round minus one.

So here we can just select.

Float.

Like this.

And we simply check for if this is bigger or greater than zero and put this in here.

And if this is greater than zero, we pick a and A, then should just be a one.

And if this is not the case, then it should be a zero.

And this is just an easy way for us to kind of shortcut this and get rid of the 0.98 and get a round

1 or -1.

And this is going to be our directional vector.

And now that we have this direction we want to multiply this by the value we want to use here.

Right.

So we can split the struct pin here.

So we can put in a value here.

And we want to multiply.

Multiply and let's just say also 2000, 2000 and yeah.

Now we have the direction which is either to the right side or the left side, and multiply this by

our horizontal launch velocity.

And we can just connect this here.

Now.

And let's try this out.

And it actually doesn't look that great.

Like you can see we get nudged over to the side a little bit if you pay close attention.

But the reason why this is happening is actually related to our jump setting.

So on the character movement component, if we look for our lateral jump friction, this is what we

set up so we can get a lot more control in the air.

However, this actually also prevents us from building up momentum in the air.

So this makes the launch character node not work properly and we need to work around that a little bit.

So before we launch the character we just want to set falling.

Actually we have to drag off this character movement component and just look for lateral.

So set falling lateral friction.

Connect this year.

And we just want to set this to zero before we launch the character.

And then after we're done, we go out of our stunned state.

We later set this back to the value that we need when we jump.

Now let's try this again.

And now the result should be quite different.

And you can see we walk into the character, we get tossed to the right, we walk into the character,

we get tossed to the left.

So actually the direction is inverted right now, because what we are doing here is we just take the

direction we already have and we just round it to a one or a minus one, but we actually want to invert

this.

So I can just use pick a minus one.

And for B use one.

And this turns it around.

So we actually get knocked back not forward.

Let's try this out like this I get knocked back.

It's all good.

And from this side also get knocked back.

It's all good.

So this is the knockback we want.

Of course it's a little bit too high, too far.

We don't want to be knocked back quite that far.

And I just think this using this pick A is a simple solution.

But you could of course also like just round this and then multiply it by 1 or -1.

So there's there's other ways you could do this.

But I think this is a simple easy solution that I want to use.

And now of course we want to turn this into a variable.

So drag off here promote the variable and just call it knockback power horror for horizontal.

And compile and save, and I played around with these values a little bit to find a good value and compound

save.

And then we have the default value.

And I want to use 1200 here.

And we want to do the same thing for our vertical velocity.

So here also drag off and call it knock back power vert for vertical.

And here we can compile and save.

And I want to use only 800 here.

And again, I just found this value through trial and error.

But you can use a different value if you want to and just compile and save.

And let's try this again.

And I think this is a lot more reasonable.

But one more thing is that we can actually kind of like steer against it right away, which is something

we don't want.

And to make sure the launch is always the same, we want to overwrite the x and Y and also overwrite

the Z, because otherwise this launch will get weaker or stronger depending on what momentum you already

have.

And we always want this to be the same so we can combine save.

And now try this.

And yeah so this is a lot more consistent now.

Like it doesn't matter what momentum we have at first.

It always is the same direction.

It's always the same height.

But since we changed the lateral falling friction like now we have control over our jump.

It's all good.

But we take damage once and the value is completely different now, so we cannot control our jump anymore.

We lost our unique jump, so after the invincibility duration is over, we actually want to set this

back.

So we have to launch character right.

And we want to have a delay here.

So we can have a retrigger double delay.

And this should be the same as our invincibility duration.

So we can just reuse this because it should be the same amount of time we can compile and save.

And here we want to just set back our following lateral friction.

Copy and paste this here to the same value we already have in the character movement component.

So here we can just look for lateral and it's 50.

So you can just type in 50 here and this is going to work.

Like this.

And right now we have control again over the jump.

But one problem with this approach is that what if later on we want to tweak this value here, then

we might forget about this value.

And then the values are different and we run into issues and bugs like that.

So a better way is to not just hard code the 50in here, but what we want to do is to take this value

on begin play, save it in a variable, and then just apply the default value back here.

So on begin play we just want to go up here.

It should probably be here on Begin Play right.

But there's already a lot of stuff going on here.

We could just daisy chain uh on here.

But it's it's a different kind of logic we want to use.

So we can just let this stand by its own.

And we can use a sequence.

And a sequence node is again, just for flow control.

It basically just executes this first and the line to the next line.

The next line you can just add more and more lines.

And sometimes if you use delays and other things you have to be careful with this.

But if the order doesn't really matter, you can use this without any issues.

And in this case the order doesn't matter.

So here what we want to do is we get the character movement component and get lateral falling friction.

And here we can just promote this to a variable.

So just drag off, promote the variable and just call the base.

Lateral friction like this.

And connect it to the.

Then double click to create a reroute.

And we can then use this value instead.

So down here where we reset our jumping the ladder following prediction instead of writing 50, we just

get the the base lateral falling friction.

And now if we just update it here in the character movement, we're like oh, maybe I want to change

the value.

Just change it here only and you don't have to worry about this because we're just going to reuse the

same value on Beginplay.

And this solves this kind of issue.

And this is a pattern we're going to use even more.

And it's a very important pattern you should remember.

We want to now implement the standard getting hit animation.

To do that, we want to open up the papers the animation blueprint.

So in here under blueprints characters players, we have the ABP player.

And before in the as the animation sequence we already registered our getting hurt animation.

Right.

So this one we are going to use this animation.

So just open up the ABP.

We can close the as and we want to create a new state.

If you don't see this just click on Anim Graph and go to locomotion.

We want to create a new stunt state here.

So like we have the run idle fall.

We also want to right click and create an animation state and just call it done.

In here.

We want to double click it.

And here play hurt.

So this is the hurt animation we want to play.

And now one problem we have here is that, well, we can pretty much get hurt in any situation, right?

We can get hurt while being idle, running, falling, jump, rise.

And we would then have to connect.

And please don't do this.

This is just for demonstration.

We would have to connect this and we would have to connect this and all of these.

And uh, also put in the conditions and things get very nasty.

And we also have to go back from the stun back to the idle.

And I'm just gonna hit control Z to go back on this.

And this is not a great way.

It's manageable.

It is doable, but your entire animation graph just becomes very complicated.

And to solve this problem, Paper XRD implemented something called animation Jumps.

And we can create a jump by right clicking and adding a jump here.

And I'm just going to call this jump stun.

And this name is very important because we're going to have to reuse this name.

So make sure it's an easy to remember name that you're not going to have any issues typing out.

And then we just connect to the stun from the jump.

Stun.

There's no condition, nothing.

We can call this jump stun from the blueprint.

So we can basically shortcut into this animation.

So now back in the player before we call the Retrigger delay here where we take damage, right?

We take any damage.

And we can just do a reroute node here.

Um, right.

So we set the lateral friction.

We launched the character.

And before we reset here we want to call this, uh, hurt animation the stun state.

So here we can then simply grab the animation component.

Right.

Because this animation component is basically controlling this animation blueprint.

And this is something we get from paper XDD.

And here we can get anim instance.

And this just gives you the currently active instance of this.

And here we can call jump to node.

Jump to node.

And this simply has a jump name and a state machine name.

So the jump name is this jump stun.

So the best way is to just really just copy it ctrl C to copy it and ctrl V to paste.

So you don't have any typos.

You can be sure you didn't mistype anything.

And the state machine name, we actually don't have to write because what we have the state machine,

it's called locomotion.

But we only have one state machine.

It's going to know that we want to use this one.

If you have multiple state machines and multiple jumps that have the same name, then you should write

the state machine name.

But for our case, we don't have to and we can just create some more space here.

Drag this over.

And put this here.

And this is just gonna tell our animation blueprint to just instantly jump to this animation.

And less than.

Try this out.

So compile and save and start out I take damage.

And you can see the animation is playing.

This is working.

The jump is correct, but we are not stuck in this animation.

And also the animation is replaying again and again, but we actually just want to have the animation

play out one time and then be stuck on the last frame, because this is a kind of common for these animations.

So the first thing we can do is in the app player, we go back to locomotion to our stun.

And here if we select the play hurt we can simply set it to loop animation.

Not false right?

Don't loop the animation.

And this.

Right.

You get the nice one frame.

So we play this frame once and then we just get stuck in this animation, which I believe is a better

way of doing this, instead of just replaying the animation again because it looks really weird.

It is not made to be used with looping.

And next.

We just want to make sure that we can go back out of the heard state, out of the stun state, go back

to the idle or whatever we are doing so we can just drag off here and go back to the idle.

And we just want to go back to the idol.

If the stun is done playing the animation, we want the animation to play out.

Once it's not looping, play it out once and then we go back to the idle.

And how can we check for the length of an animation?

Well, we can just go in here and we can just look for stun actually for hurt, because that's the name

and we can look for time remaining hurt.

So this will tell us if the animation is playing, how much time is left.

And here we simply have to check for smaller equal than zero.

So it's just going to play once and it's going to transition us back into the idle state.

So compile and save.

Like this.

And it plays out once you can see it play out once and then we just go back to the idle.

And even if we go back to the running because there's actually a shortcut built into this animation

blueprint, to my understanding, if we try to go from stand to idle, it will then also try to go,

to run, to fall, to jump right in the same frame so we don't have to worry about, like going from

stand to run or fall or jump, right?

It will then automatically know if it can transition from idle into the other ones during the same frame.

One problem we still have, though, is that if we go here and even while we're stunt, we can still

shoot while we are being stunt and being knocked back, which is not ideal.

To do this, we need to go to the DB player and create a new variable and just call.

It is stunt and this should be a boolean.

So this is fine.

So what do we do here.

So again like we we get launched.

We play the hurt and stun animation.

So here we just want to set this stunt to true.

And open up some space here.

Like this.

Set it to true.

And then we want to make sure that if we are stunned, we are not allowed to shoot.

So we can go to our IA shoot.

Where is it?

Here.

IA shoot right.

And we can then just drag this off to the side to create some more space.

And add another branch here.

Right.

So started branch.

Like this.

And we can get the stand.

And we don't want to be able to do this if we are stunned.

We want to be able to do this if we are not stunned.

So we can get not boolean.

And connect this here.

So if we are not stunned, we are allowed to shoot.

To clean this up a little bit.

And we also want to use the same pattern for our moving.

Right.

So we also don't want to be allowed to move while we are stunned.

So we can just use the I move right on triggered.

Going here.

And on through.

And now we just want to reroute this a little bit here.

Can actually double click here to create a new node.

Put it in here, select all, press Q, and now this looks a lot better.

So let's compile and save.

And here I get stunned.

I try to shoot, I cannot shoot.

And now I also cannot move anymore because we need to reset the stun state.

But actually, yeah, it's working.

I can move, I can shoot, I get stunned, I cannot shoot, I cannot move, but now we just need to

take care of resetting this.

So back in the player we want to go back down where we take damage.

Right.

Take any damage here we set is stunned to true.

And here we then want to remove the stun state.

And we don't want to be stunned for the entire duration of the invincibility, because this is too long.

And also the invincibility should allow the player to reposition and get in a better position.

So we actually want to use a sequence here again, which we did also on Beginplay.

So we do this as a separate thing, and then we can also execute another logic after this that is unrelated.

So here we can also use a retrigger delay.

But here we want to then set a stand back to false.

And for now, let's just try out 0.4, maybe like this and compile and save.

And go in here.

Right, I cannot shoot, it's fine.

But then I wait a little bit and I can shoot again.

After 0.4, we properly touch the ground and we can shoot again, so this feels like the right value.

So let's turn this into a variable and promote the variable stun duration.

And this is how it works.

So there is one thing we could improve upon.

We can just compile and save that.

We are now kind of manually matching the duration of the stun duration, and we are matching it to the

duration of the actual animation itself.

So instead of just using the animation length, I think it actually is better if we just get the owning

player and we look for is stunned, get is stunned, and not boolean.

Not bullying like this.

So we transition back into the idle animation if we're not stunned anymore.

So there could be no disconnect between our instance state in the player blueprint and the actual animation

length.

So now if we compile save.

Let's try this out.

Right.

So this is better.

Now these are synced.

And this animation is a little bit longer.

And now if we want to adjust the stand duration for gameplay purposes, we don't have to worry about

the animation because it's going to follow along.

Right?

So we could, for example, just put stand duration to two seconds just to show how this works.

Right?

And now the animation keeps on playing as long as the stand duration.

And this is just a better solution in this case.

But let's set it back to 0.4 which is a nice value.

But this gives us a lot more flexibility instead of just waiting for the animation to play out.

And congratulations if you made it this far.

This was a bit of a complicated lesson, but a stand system like this and invincibility are things you're

going to use in pretty much all of your games.

So I hope you got a basic understanding of how these things work, and can also replicate this in your

own games with some more practice.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.