Enemy - Script #3

18 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€92.30
List Price:  €129.22
You save:  €36.92
£79.14
List Price:  £110.81
You save:  £31.66
CA$135.92
List Price:  CA$190.30
You save:  CA$54.37
A$153.17
List Price:  A$214.44
You save:  A$61.27
S$134.71
List Price:  S$188.59
You save:  S$53.88
HK$782.26
List Price:  HK$1,095.19
You save:  HK$312.93
CHF 90.56
List Price:  CHF 126.79
You save:  CHF 36.22
NOK kr1,076.34
List Price:  NOK kr1,506.92
You save:  NOK kr430.58
DKK kr688.47
List Price:  DKK kr963.88
You save:  DKK kr275.41
NZ$166.49
List Price:  NZ$233.09
You save:  NZ$66.60
د.إ367.19
List Price:  د.إ514.08
You save:  د.إ146.89
৳11,000.23
List Price:  ৳15,400.77
You save:  ৳4,400.53
₹8,335.05
List Price:  ₹11,669.40
You save:  ₹3,334.35
RM473.25
List Price:  RM662.57
You save:  RM189.32
₦139,656.03
List Price:  ₦195,524.03
You save:  ₦55,868
₨27,872.43
List Price:  ₨39,022.53
You save:  ₨11,150.09
฿3,637.73
List Price:  ฿5,092.97
You save:  ฿1,455.24
₺3,222.80
List Price:  ₺4,512.05
You save:  ₺1,289.25
B$497.67
List Price:  B$696.75
You save:  B$199.08
R1,888.37
List Price:  R2,643.79
You save:  R755.42
Лв180.67
List Price:  Лв252.95
You save:  Лв72.27
₩134,942
List Price:  ₩188,924.20
You save:  ₩53,982.20
₪366.06
List Price:  ₪512.51
You save:  ₪146.44
₱5,625.18
List Price:  ₱7,875.48
You save:  ₱2,250.29
¥15,118.78
List Price:  ¥21,166.90
You save:  ¥6,048.12
MX$1,663.06
List Price:  MX$2,328.35
You save:  MX$665.29
QR365.44
List Price:  QR511.63
You save:  QR146.19
P1,373.02
List Price:  P1,922.28
You save:  P549.26
KSh13,148.68
List Price:  KSh18,408.68
You save:  KSh5,260
E£4,723.53
List Price:  E£6,613.14
You save:  E£1,889.60
ብር5,694.53
List Price:  ብር7,972.57
You save:  ብር2,278.04
Kz83,612.73
List Price:  Kz117,061.17
You save:  Kz33,448.44
CLP$98,024.19
List Price:  CLP$137,237.79
You save:  CLP$39,213.60
CN¥722.49
List Price:  CN¥1,011.52
You save:  CN¥289.02
RD$5,928.03
List Price:  RD$8,299.48
You save:  RD$2,371.45
DA13,469.95
List Price:  DA18,858.47
You save:  DA5,388.52
FJ$225.25
List Price:  FJ$315.36
You save:  FJ$90.11
Q781.84
List Price:  Q1,094.62
You save:  Q312.77
GY$20,987.69
List Price:  GY$29,383.60
You save:  GY$8,395.91
ISK kr13,817.61
List Price:  ISK kr19,345.21
You save:  ISK kr5,527.60
DH1,010.57
List Price:  DH1,414.84
You save:  DH404.26
L1,763.81
List Price:  L2,469.40
You save:  L705.59
ден5,677.01
List Price:  ден7,948.05
You save:  ден2,271.03
MOP$807.66
List Price:  MOP$1,130.76
You save:  MOP$323.09
N$1,895.98
List Price:  N$2,654.45
You save:  N$758.46
C$3,689.21
List Price:  C$5,165.04
You save:  C$1,475.83
रु13,357.88
List Price:  रु18,701.57
You save:  रु5,343.68
S/371.02
List Price:  S/519.45
You save:  S/148.42
K383.60
List Price:  K537.05
You save:  K153.45
SAR375.02
List Price:  SAR525.04
You save:  SAR150.02
ZK2,548.47
List Price:  ZK3,567.96
You save:  ZK1,019.49
L458.83
List Price:  L642.38
You save:  L183.55
Kč2,334.38
List Price:  Kč3,268.22
You save:  Kč933.84
Ft36,425.52
List Price:  Ft50,997.18
You save:  Ft14,571.66
SEK kr1,059.50
List Price:  SEK kr1,483.35
You save:  SEK kr423.84
ARS$85,666.43
List Price:  ARS$119,936.42
You save:  ARS$34,269.99
Bs695.09
List Price:  Bs973.16
You save:  Bs278.06
COP$389,673.99
List Price:  COP$545,559.18
You save:  COP$155,885.18
₡50,509.65
List Price:  ₡70,715.54
You save:  ₡20,205.88
L2,474.33
List Price:  L3,464.17
You save:  L989.83
₲736,638.54
List Price:  ₲1,031,323.43
You save:  ₲294,684.88
$U3,781
List Price:  $U5,293.55
You save:  $U1,512.55
zł398.17
List Price:  zł557.46
You save:  zł159.28
Already have an account? Log In

Transcript

Welcome back everyone in the last video we finished up making this mando calculate damage macro inside of our BP enemy character base. In this video Our goal is to create the script to receive damage from an outside source from an outside source like a fireball or electro Spark, as well as create some script to damage our player if the enemy touches us so that we can actually see our HUD health working properly, let's deal with applying damage to our enemy when we hit them with a fireball or electro Spark. So I am going to jump over to our Event Graph inside of our BP enemy character base. And if you pause between videos here, this is the directory on how to find your BP enemy character bass. Double click on her to open her up in any Event Graph I already have my calculate damage macker out here which you can get by left clicking over here dragging and dropping it into your graph.

And directly to the left of this I'm going to right click and bring in an event called any damage this guy so in the last video, we looked at our BP fireball in our BP electro Spark, and each of these blueprints, had a function node called a ply damage in which we are plugging in a damage value and a damage type that's in our BP electro Spark. This is in our BP fireball in all this information is coming from our fireball attributes and our electro spark attributes that were populated inside of our BP player. So as soon as this gets passed into this node, right apply damage. This is is actually going to tell this event any damage here inside of our enemy base character to fire out we're going to take our execution pin plug it in here how much damage did we do well that is going to be supplied by this information right here the base damage and what type of damage did they do?

Well again here in our fireball, we plugged in a damage type into our damage type class. So let's just pass that along as well damage type incoming damage type. All right now and based upon all the math that is taking place inside of our calculate damage macro here which you can actually see by just double clicking on it. Remember this awesome script. Now we can have different effects happen based on the result of that math and if our character was vulnerable or resistant to that damage type So this is how we're going to do this, I am going to bring in a reference to our mesh. Our mesh has its transform set right down there at the character's feet.

I'm going to bring in a reference to our mesh and I'm going to drag off of this and say get the world location of that mesh basically right at our character's feet there. And the reason I want to do that is because off of this return value, I'm going to say spawn emitter at location. I'm going to bring in one of these and slop the emitter as p underscore flame explode. This is in the Infinity Blade effects pack By the way, you can slot in whatever makes you happy. And then I'm going to copy this node by hitting Ctrl C and Ctrl V to paste and I'm going to plug in this get world location into this spawn emitter at location. Okay, and what I'm going to do is I'm going to say if our character is vulnerable to a given damage type, which currently we've got set to fire, we're going to spawn this flame explode, only, I am going to make the scale here two times is big in the x, y and z.

So it's going to be a more grand explosion if it actually kills them. However, if they're vulnerable to that damage type, but it does not kill them, it only damages them. I'm going to plug into this emitter, which I'm going to say play that flame explode. Let's just keep the scale at one. And I'm saying to spawn this at our meshes world location basically at our feet here, just because that's where the particle effect is going to look most natural. And I discovered that through testing.

Okay, so with this done, I'm gonna move this up a little bit. We'll see this come into play in just a little bit. Now I'm going to highlight these nodes right here, left click and drag, I'm going to hit Ctrl C, and then I'm going to hit Ctrl V down here to kind of paste in a nother series only for if our character resists that given damage type. I'm going to plug into these two. Well, I don't want to do the flame explode for if they resist this damage type. Remember, our enemy character here is going to resist some lightning damage.

So I'm going to set our emitter here to be there's one called line to point underscore, blast, underscore, lightning. That one right there, line two point blast lightning 00. And this also is in the Infinity Blade effects pack. And again, you can use whichever one you want. So I'm gonna slay a slot that in there is Well is line two point underscore blast underscore lightening slotting that into both of these for our resistance the top most one if it's going to kill our player they're said they're resistant to damage type but they're still gonna kill them. I'm gonna make the scale be 1.5 1.5 and 1.5.

However if they are resistant to that damage type and it does not kill them, I'm going to change the scale here to be point seven, five in the x, the y and the Z. Okay, so we've got different particle effects that are gonna play depending on if they're vulnerable or resistant to them. Now I'm going to select these nodes again. Ctrl C Ctrl V and paste another copy down here for if we calculate damage and our character is neither resistant nor vulnerable, so I'm going to set normal death into here. Normal damage into here only. I don't want to play this at the location of our mesh.

For this one I'm going to play at the location of our capsule component. What am I going to play and our capsule components location, and let me just jump to the viewport our capsule component has the transform basically right in the middle. So imagine this particle effect that we're about spawn gonna be playing right in the middle there. For this one, we're just gonna do a regular explosion good old p explosion. p underscore explosion p underscore explosion and if it kills them, I'm gonna set the scale here to be either flip my page and notes I'll set it to be twos across the board. Two, two and two.

And if it doesn't kill him, I'm going to set the scale to the one, one and one now. Note that it actually kills the character. Whether it be the vulnerable death The resistant death or the normal death, I need to bring in a destroy actor node. So it's gonna, this one is going to destroy gonna hit Ctrl C. resistent death This one is going to destroy so essentially every other one here and then normal death. This one is going to destroy as well. Okay.

So let me left click and drag around all these notes. Hit the C key and I'm gonna say Apply. Let me zoom up a little bit apply damage to enemy. All right, let's quickly Compile and Save and we should be able to test this out. So just clicking on play over here. Okay, our character is not fireball so let me shoot out a fireball and in the upper left hand corner of my viewport you should see how much damage our enemy has been output to the screen as well.

So here we go fireball against our enemy character which they are vulnerable against. Boom, you can see a big old explosion you saw 0.0 up there in the left hand corner of the screen. Let's do a few things here. Let's go into our MV test map. Let me select my enemy character. I'm going to go all the way down to my default settings so I can modify some of this to do where was it, okay, so I'm going to change my vulnerable multiplier here to be Simply 1.5 so that's not going to be enough damage to kill them.

Fireballs do 50 damage times 1.5 should 1.5 should now be 75 damage. So now watch what happens when I jump in and play. The explosion should be a little bit smaller and it should not destroy our character the first time a little bit smaller and you see 25 health, this next one should kill them and that effect should be bigger. Okay, so we saw that play let me select my enemy character once again here. We're gonna set this back to zero. How about I change the given spell that I'm casting to my lightning.

Okay, let's try lightning next. Let me just click play here. So I am in the editor, I'm just going to hit Shift plus f1. That's going to give me control of my mouse. And now if I select my BP player that has now appeared in my world outliner I'm going to come under I'm going to come under my player info my be magic slotted which I've made available here in the editor this be magic slotted variable here in my BP player. Now remember, I made this be magic slotted variable, I clicked that eyeball icon so that I could edit it in.

In the editor over here, I'm going to change this over to be electrical Spark. So now let me bring on my window once again. And now we got to click on my window to give myself access to it again. Now when I hit the one key, I should be doing electrical Spark. Look at the damage value that's gonna be up output in the upper left hand corner of the screen as well as the particle effect that's going to play when it hits my character. Okay, so 50 damage.

Okay, let me do it. Once again. Missed on that one. Let me get a little bit closer and actually I can't catch it anymore cuz I'm out of mana so let me jump out of here jump back in and play I'm still doing fireballs I gotta go back to let me jump in and play shift plus f1 gonna grab my player and I'm gonna say hey do you lecture spark alright so one to damage them with the lecture spark effect and then one again this one should killer effect was just a little bit bigger so you have now created a damage script for your enemy pretty sweet and you've seen how you can select your enemy character here and you can swap out all kinds of things about your enemy straight away from the Details panel with those exposed variables. You can change things like what is their damaged vulnerable class, their damage resist class you can even modify that multipliers and their health values.

That is all well and good. Now how about we move on to creating a little bit of script where our enemy can actually damage us, this should be relatively simple to do. So let's just jump back into our BP enemy character base. I am going to add a brand new variable over here and I'm going to call it attack damage. This is how much damage that our enemies going to deal to us. I'm going to compile here and save.

And sure I'll make this instance editable as well and I'll say they're gonna deal 25 damage to us. Now with that done, I need to find a new spot here in my Event Graph away from our apply damage. Let's just go over to the right here a little bit. And I am going to right click and bring in an event. Hit So often the event hit I'm going to drag out of the other actor in find out cast to BP player. If the thing that hit us the enemy character was the BP player.

If it was, I'm going to drag out of this as BP player. I'm going to type in apply damage this function right here. And I'm going to create some space between the two. I'm gonna double click on this wire here once in twice to bring in a reroute node because I'm going to put something in between here What am I going to put in between here I'm going to drag out of my BP player and bring in a do one snowed. Why do two one snow because when our BP player bumped in to our enemy character, I only want to apply that damage one time and not have it repeat itself quickly. So I'm gonna say do it once apply that damage and then off of the apply damage.

I'm gonna drag out a one Bring in a delay node and we're gonna make this delay for let me just snug these up a little bit closer like that. I'm gonna bring in a delay a half a second 0.5 seconds and I'm gonna say after half second delay if BP player you bump into the enemy character, we're gonna say you can get damaged once again. Okay, so you saw how that we're just resetting that do once known so it can happen again. Now how much damage do we want to deal well, let's plug in our Attack Damage variable here which says 25 damage. Okay, so we've got this applied damage going on here inside of our BP enemy character base. Let's quickly Compile and Save.

But our BP player right now does not have an event to receive any damage and do something with that. So let's fix that. Let's go back to our BPP key player quickly in content, Metroidvania, blueprints characters BP player. Let's jump over to the Event Graph tab here we've got some test scripts where we were updating our health by just tapping the H key just showed that our health meter would actually work. And right below my test scripts, I'm going to right click, and I'm going to type in event, any damage so if we receive any damage, like we're doing over here in our BP enemy character, we're saying the damage actor is our BP player, we want to apply damage to the BP player. We're going to drag out of here and simply say, update health.

Here is my update health function that I've created inside of my BP player, I simply could have gotten it by dragging and dropping into the graph is well, how much damage should be applied. Well, we're going to pass that on into our incoming damage of our update health node. And again, that is determined by the damage in my BP enemy character that we're specifying right here that we're feeding into this applied damage function. So with our BP player, now having this little bit of script I can compile in save. Let me just left click drag around this tap Escape key and say player receives damage. Let me compile and save one more time.

Now I should be able to jump in and play and when I run my character into the enemy, watch my health in the upper left hand portion of my HUD. We go down to 75. We go down to 50. We go down to 25 and we go down to zero now we're not actually doing anything when our health is down to zero, but we could Alright guys, that is Going to Do it all for this series of videos now we've got an enemy character that we can damage with our fireball and our electro spark and we've made it so that our enemy character can damage us if we run into it. That'll do it all for this one. We'll see you guys in the next one.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.