All language subtitles for 003 Enabling the Player to Shoot[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 projectiles by themselves are complete, we want to implement a way for the player to actually

shoot them instead of us having to drag them into the world.

First, we can go here to the projectile and just hit delete on the keyboard.

Get rid of this one because we want to spawn it when shooting.

The first thing we need for that is of course a button binding, because now we only have a button for

moving and for jumping, but we need to set up buttons for the shooting.

And if you remember, we use the enhanced input system for that.

So we can go to content go to input.

And we need to create a new action.

And I can just right click here go to input and Input action just called IA shoot.

And in here we don't have to change anything because it is just a button digital wool.

It can either be active or not active.

And we then need to go to our IMC action.

And here we also need to set up the button for shooting.

And if you remember, I set the spacebar for jumping, but also K because if we only have the spacebar

it kind of gets awkward.

Like where do we put the shoot button.

So if I add the mapping here go to I shoot.

And here open it up I want to put this on J.

Because now we have shooting on J and jumping on K.

So we have the same position on the keyboard as ten finger typing.

Now we can save this.

And we of course need to set this up in the player.

So in the content drawer go to blueprints Characters player and the BP player.

On the event graph, right?

If you're not here, click on the event graph.

We have our jump event.

We have our move event.

So down here you can just right click and go for IA shoot which we just created.

And spawning a projectile is extremely easy.

So here again we don't want to use triggered because triggered happens on every frame that the button

is being held.

We just want to shoot on started when we press the button for the first time.

And here we can just spawn actor from class.

And this just lets us pick any class that we have created or classes that are available in Unreal Engine

from the get go, and here we can just look for our projectile.

And for this one, let's first just start out with the BP player projectile regular, because this is

our default projectile.

And later on, based on some conditions, we're going to have to pick between the regular one, the

partially charged one and the charged one.

But for now, just the regular one.

And the thing we have to give it is a spawn transform, because we can spawn the actor, but we have

to tell him where is it supposed to spawn, which rotation is it supposed to have, which scale is it

supposed to have?

And usually we just want to right click this split struct pin.

We usually don't want to mess with the scale, otherwise the pixel art is going to scale with it and

it's going to look very nasty.

So usually you just keep this as one for the location.

Let's just start out simply by using the player's location so we can get actor location.

And later on we're going to have an offset and want to shoot it actually from the gun.

But for now, just start with this.

And here again just get actor rotation to always shoot forward.

And this is the simple way we can start and then we can make adjustments to it.

And for the collision handling override, just to make sure nothing is going to prevent this from spawning.

Just say always spawn ignore collision.

One more cool thing we can do if we spawn an actor, we can actually set the instigator.

And if we press here, we can also set the owner.

And if you don't have any experience with this, you might not know why this is useful, but this is

a very easy way to pass a reference into this actor.

So inside of this actor, we can then just get owner and can perform certain actions on the owner.

So we're going to use this later for the shot recovery.

Like I said before, we have to destroy the projectiles if they leave the screen.

And then if a projectile is destroyed, we need to tell the player, hey, it was destroyed, you can

shoot again.

And for that it is really useful if we just pass a reference of the player in here.

So for owner we can just get self.

And we can also set this to the instigator, because the owner in this case is also the instigator.

And this is all it takes to simply spawn a projectile.

So let's try this out.

And we want to get out of simulation mode.

Just go back to selected viewport.

And again, very important.

Click into the viewport to take control of the character.

If I press J.

Now you can see that we spawn the projectile and there are a couple of issues.

Now you can see that we are being pushed back by the projectile and it instantly explodes.

And this is because of the collision settings.

And this is the next thing we want to do.

We want to make sure that the projectile is blocking with walls, but it is only overlapping with characters,

so that weird things like this don't happen.

So now we want to open up the projectile base.

So go to content blueprints projectiles and yeah, the projectile base because we want to apply this

to all projectiles.

And here we want to select the sphere because the spheres are collision.

And on the right side scroll down until we find the collision settings.

And here you can see here we have block all dynamic.

And the problem here is that we are blocking the pawn.

And the player's capsule is a pawn.

So if we spawn the bullet we kind of push ourselves away because they cannot exist in the same space.

We want to set this to overlap, but as you can see, we cannot select anything here.

A very quick and dirty way of doing this is to just go here and set this to custom.

And for --, we just go to overlap and this is it, right?

So now we can go back here.

I can press play.

And we have solved the issue.

And in many cases this is a good enough solution.

But the projectiles are actually very important for our game.

So I think we should implement a custom channel for the projectiles just to make sure we manage them

correctly.

And don't just set everything to custom and then lose track of things.

We can easily create a new item on this list by going to Edit Project Settings.

And under engine.

We have collision.

Right.

Engine collision.

Click here.

In here we have the object channels, the trace channels and the presets.

An object channel is something you can see here right.

The object type.

If we add another object channel it's going to show up in this list.

And it's also going to create another entry down here which we can then assign things to.

So we're first going to use this so we can create a new object channel just called projectile.

And for this one we can also set the default response and it could be ignored, overlap or block.

And in this case block is the best one because as I said before, for blocking to actually work, two

objects need to block each other.

If only one side blocks and the other one only overlaps.

Overlap is the one that is actually going to be active, so it is safer to have it on block by default,

and we can then make changes in the projectile itself.

So here we can just click on accept.

And just look at the projectile compile for this to show up.

And now here we can see that we have the projectile.

Here we have the projectile here as well.

Right.

So we added this to the list.

And this is fine right.

We could just say oh this is a projectile.

And then we can say it should only ignore other projectiles or overlap other projectiles.

But again this is a little bit hard to manage if we want to use this over multiple blueprints.

So we also want to add a collision preset here.

So we can just pick it from the list.

And all of these settings down here are always going to be the same.

And we can do this here again in project settings.

So trace channels we don't have to worry about.

Now these are for line traces and things like that for the camera tracing.

But presets are the one we want right.

So this preset collision preset we want to add one here.

And we can just click on new.

And the name is going to be projectile again.

And we need to set up collision enabled.

So this just means no collision query only is if you're only looking for overlap events.

If you don't care about physics, if you don't care about block events.

But we actually do.

And physics is only block events, things like that.

But we actually want both because we want to look for overlaps.

We also want to look for blocking.

So collision enabled query and physics is the correct one in this case.

For object type we want to pick our projectile which we created before.

And for the description we can just write something here like used for all types of projectiles.

And here we can then set up our channels.

So actually the default we want to have is ignore.

Because most of these things we don't really care about we do want to be blocking world static.

We do want to be blocking world dynamic like the floor we had before.

We don't want to be blocking pawns, but we want an overlap event.

So we want to be overlapping pawns.

We don't care what physics body.

This is the collision site of a static mesh and things like that.

We don't care about vehicles.

We don't care about destructible and projectiles.

Well, maybe if you want to have something where two projectiles can like hit each other and cancel

each other out, we would want to overlap.

We're not going to implement this in this game, but because the possibility of that is there, I think

it's better to set it to overlap.

So we have the option later and we then click on accept.

Right.

And this is all it takes for us to create a new object channel and a new preset.

So again compile and save here.

And we then have the collision presets instead of custom we just pick our projectile.

And everything in here is now just set up the way we did it in the project settings.

And we can then reuse this collision preset over multiple blueprints.

And again, this just does the same thing we did with custom.

But this is a lot cleaner.

It's more reusable.

And this is something I found very intimidating as a beginner to go in here and set all of this up because

there's so many different settings and you're not quite sure.

So I hope this explanation gave you some more confidence in actually using these custom channels by

yourself as well, because it's actually not that hard to use them.

Now again, we can just go back to the map and test this out so start and I can shoot.

It's all good.

We don't block the player.

We don't care about the overlap events yet.

That's something we're going to use once we have the enemies implemented.

But this set up the groundwork for that.

And just to show you, blocking with the wall is also still working.

And even though functionally our shooting is working now, it still doesn't look great, right?

We aren't playing an animation and the bullets are just coming outside the middle of the body of our

character.

So we want to adjust the position.

We want to play animations, and we also want to make sure that we can't just spam and shoot infinitely.

And we're going to take care of this one by one.

The shoot animation for these Mega man type of games is usually very different from most other games.

In most other games, shoot animations have a startup of a couple of frames.

They have some active frames where the movement is going to be locked while you shoot, and then they

have some recovery frames.

And this is just an example of a beat'em up I'm making where this is true.

The character takes some time to prepare the projectile shoots, it is locked in place and then can

start walking again after the recovery.

However, in these games it's actually quite different.

Usually the shoot animation is instant once you press the button and you can keep on walking around

even while you're shooting, you're not locked in place or anything.

There is no recovery and you can also like shoot multiple times right after another if you have the

shot energy.

So the way we have to implement this is a little bit different, and we have to think of it more as

a state rather than a one off animation.

And the shoot animation can also seamlessly transition between idle walking, jumping, falling, and

a lot of different states.

And here's just a simple graphic of what this is going to look like.

We're gonna have the regular idle animation.

We're gonna have the shooting, idle animation, regular run animation, the shooting run animation,

regular jump rise animation, shooting jump, rise, falling, regular and falling while shooting.

And we can seamlessly transition.

So if we start shooting while idle, we'll go into this state.

And the shooting state will stay active for a while.

So even if we stop shooting but we go into the walk animation, it will then transition from this to

this and then over here, and then it will just go back to the regular run state.

And this might sound very complicated to implement, but Paper XRD makes it very easy to do this in

the game.

We just need to add a boolean to the player first.

So here we can go to variables and click on here.

And just called is shooting.

And this should be a boolean because this can only be true or false.

We want to compile and save.

The default value should be false because we are not shooting if we spawn in and then before we spawn

the projectile after we press the shoot action, we can drag this out here and set is shooting.

Connect this here to true very important.

Click here.

To make sure we set shooting to true, and then we spawn the projectile later on.

We're also going to have to set this to false again, but for now let's just set up the animation.

So open up the content drawer in the blueprints characters player.

We have the ABP player the Animation Blueprint.

So open this up.

And like I said before, in the event graph we get a reference to the player and save the owning player

here.

And this is great because now we can simply go anywhere and just ask for is shooting.

And this will allow us to set the state in our animation graph.

So not just here in the event graph.

Also in the animation graph we can now go here and let's start with the idle.

So we can go into the idle.

And here like we used before, we can just go to the output animation and select animation by bool.

And this is a perfect use case for this node.

So we can then get the owning player and is shooting.

Just straighten this up with Q and select this as the condition.

So if we are not shooting so false animation just play idle.

Just like we did before.

But if we are shooting, we want to play.

Ideal shoot.

And again, this animation is available only because we set it up in the as player before the animation

source.

And this is all it takes.

We just check.

Are we shooting?

If we are shooting, play the idol shoot.

If we're not shooting, play the idol.

Very simple.

And just compile and save to show this off.

And I press J to shoot and you can see we go into the shoot animation.

There still is no shoot animation for the jumping and walking, so we just go back to the regular one.

But if we just stand still again, you can see the shoot animation is playing and we just have to repeat

the same step for all of the other animations now.

So back in the app player, we just want to get all of this and hit control C to copy.

We can go back out to locomotion and let's start from run.

And in here again we can drag this off to the side.

Control V to copy control V to paste this in connect this here.

And again if we are not shooting we just want to play the run.

If we are shooting then play run shoot.

And the same thing is going to apply here.

And we go back, do the same for jump rise again, drag it off, control V to paste it in.

Again.

We are not shooting.

Just play jump rise.

If we are shooting, jump.

Rise shoot.

Like this.

And lastly, do the same thing for fall.

Drag this off here.

Again connect this here.

We are not shooting.

So false is just fall and then play fall.

Shoot.

Just like this.

Very simple.

It's just the same pattern we use over and over again.

We can compile, save and that and then test this out.

Display I press shoot, I go into the shoot idle.

If I walk I go into the shoot walking and I jump, I fall and we just seamlessly transition between

all of these.

But now the shooting is just always active, so we need to set back the shooting state after a while

after shooting.

So what we can do now is to after we spawn the projectile, we can just add a delay.

And you can see that there is a delay and a retrigger delay.

And we actually want to use the retrigger delay.

But I want to show you why the regular delay is a bad choice here.

So we can just go here and say after 0.4 seconds, which is just the value I found while prototyping.

I was just trying out different ones and seeing how it feels.

We can then just copy this one control C, control V, and make sure to take off the check mark to set

this to false.

Right.

So we shoot.

And then after 0.4 seconds we just set the is shooting back to false.

And we can just compile and save.

Like this I should one time only.

We go on to the animation and we go back, right?

So this is working.

This is working just fine.

But what happens if I press the button twice?

So the second animation just kind of stops almost instantly, right?

Because what happens here is that I press the button once.

And all of this executes and the delay starts.

And if the delay starts, this means that after 0.4 seconds, we're just going to set this back to shooting.

So what happens then is let's say after 0.3 seconds I hit shooting again.

We just execute all of this again and we start the delay again.

But the first delay is still active.

So even after just 0.1 seconds we set it back.

And the second animation is very short.

So what we can do here is to just use a retrigger double delay instead.

And get rid of this one.

And just use this one instead and set this to 0.4.

And we can just compile and save and try this out.

And now again I try to shoot pretty late.

But you see, the animation doesn't reset quickly.

It's always the same amount of time.

And this is what a retrigger delay is great for.

All this does is that if we already have an active delay, but we call this again, the first delay

will just be thrown out and forgotten about and this just becomes the new value we use.

So you always got to be careful with delay and retrigger delay and see which one makes sense.

In this case, retrigger delay is the right choice.

Now we just want to change this duration to a variable so we can easily change it.

We can just drag off here and promote the variable.

And just call it shoot anim duration.

Like this.

And this just makes it easier to manage, compile and save.

And we can see that the default value is 0.4.

So if we want to change this later, instead of just having to look everywhere for this, we can just

go here and change the value very easily.

Next up, we want to fix the position where the projectile is being spawned.

Now when I shoot, it doesn't look too bad, but you can see it kind of comes out of the middle of our

character instead of where the gun is, where the muzzle of the gun is.

So we want to slightly adjust the position, and this becomes even more apparent if we jump and do other

things like that.

So we just want to slightly adjust the position of the projectile being spawned.

There are multiple choices we have for doing this.

And the first thing that comes to mind, if you know about all the features of paper, 2D is a sprite

socket.

And I'm just going to show you how this works.

So we can go to content draw.

We can go to content paper assets characters and player.

And in the frames.

This is where all of our sprites are.

So we just want to look for a one off the frames that has shooting.

Right.

So this one for example idle shoot zero.

Open it up.

And here on the right side you can see sockets.

So I can just go here and add a socket.

And you can see here socket zero one.

And if we open this up and the transform you can see that we have the location rotation and scale.

So this lets us set a specific position rotation and scale on every single sprite individually.

So we can just drag off here for example and go to the gun like here.

So this is the muzzle of the gun right.

This is where you want the projectile to spawn.

And rotation 000 means that it is facing forward.

So you can see this red arrow which is also correct.

Right.

We want this location and we want this rotation for the bullet to come out of.

So this looks like a good solution.

However sadly this system can be quite buggy sometimes it works out great and I'm using this extensively

in my bitmap.

I didn't have any problems.

However, then I was making another game and then it just didn't work.

So this is actually a solution.

I don't want to recommend too much anymore.

You can try it out for your other games and see if it works, but there can be issues and I just want

you to be aware of this.

So in this case, there's actually another quick solution we can use.

And we're not going to use sockets for this game.

So we can just go back here to the trash and just throw it out.

So we're not gonna have a socket anymore.

And then just save the sprite and go back.

The way we're going to do this is in the BP player.

We can go to the viewport just so we see what's up.

And here on the capsule component we want to add a scene component right.

So utility scene and the scene is just a very simple thing right.

It has a location rotation and scale pretty much like a sprite socket.

So it's something very similar.

And I'm just going to call it shoot pos.

And what we can do here now is the same thing.

We can just drag it around and set it to a certain location that we want to use.

But the problem we have now is that we are playing the idle animation.

So it's very hard for us to see where we actually want to position this.

And I'm going to show you a little trick that we're probably going to use a couple of times.

We can go to the sprite.

And here for the source flipbook we just look for shoot.

And we want the player idol shoot.

Right?

So now we can see the idol animation here.

And this one doesn't have a lot of movement, so it's fine.

But we could also go to play rate and just set this to zero on the correct frame so it doesn't move.

And then we can set our shoot position to where we want it to be.

And we can just drag this over here.

To like 60.

Maybe a little bit more inside.

Yeah, 50.

And this is too big of a jump.

This ten is too big of a jump.

So we can go here and set the snap size to five and go down here.

Right.

So now we're in the middle of the gun I think this is a good location.

If you want to make some small adjustments.

You can also just type in the number right.

You can see that we're not exactly in the middle.

So maybe you can go to four which is even better.

And yeah this is just the position we want to have for shooting.

And this is how we set it up.

So now we can just go back to the sprite, make sure to set the play rate back to one and also just

play the idle animation again player.

Play your idol.

Right, so everything is back to normal.

But now we have our shoot position here, which we can use in our blueprints to determine where the

projectile is being spawned.

So back in the event graph, we want to go to our IA shoot.

And here, instead of using the Get Actor location for where we spawn the projectile and the rotation,

we want to get this from the shoot position.

So we can just delete both of these.

Hit delete on the keyboard, can grab out the shoot position and here we want to get world location.

Like this.

I just use this for the spawn transform location and we want to get world rotation as well.

And connect this here again scale.

We just want to keep one.

We don't want to mess with this and this is all we need.

Now we know where the scene component is in the world and we tell that to the projectile we spawn.

And we can just compile and save and go here.

And now when I shoot.

You can see that the bullet spawns a little bit in front of us like this.

And you can see it also looks fine if we walk.

It also looks fine if we jump so gladly we don't have to prepare a different position for each one of

these animations.

There is going to be a case later on for the climbing animation, where the position is a little bit

different, and I'm going to show you how we can take care of that case as well.

One problem we still have is that I can just keep on shooting infinitely, and there is no cooldown.

There's no cap on how many bullets I can have, and that is what we're going to take care of in the

next video.

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