Fireball - Use Script

17 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.78
List Price:  €129.90
You save:  €37.11
£79.40
List Price:  £111.16
You save:  £31.76
CA$136.11
List Price:  CA$190.56
You save:  CA$54.44
A$154.13
List Price:  A$215.78
You save:  A$61.65
S$135.08
List Price:  S$189.12
You save:  S$54.03
HK$782.28
List Price:  HK$1,095.23
You save:  HK$312.94
CHF 90.61
List Price:  CHF 126.85
You save:  CHF 36.24
NOK kr1,085.23
List Price:  NOK kr1,519.37
You save:  NOK kr434.13
DKK kr692.01
List Price:  DKK kr968.84
You save:  DKK kr276.83
NZ$167.80
List Price:  NZ$234.94
You save:  NZ$67.13
د.إ367.19
List Price:  د.إ514.08
You save:  د.إ146.89
৳10,976.08
List Price:  ৳15,366.96
You save:  ৳4,390.87
₹8,339.52
List Price:  ₹11,675.66
You save:  ₹3,336.14
RM473.25
List Price:  RM662.57
You save:  RM189.32
₦141,842.81
List Price:  ₦198,585.61
You save:  ₦56,742.80
₨27,810.04
List Price:  ₨38,935.18
You save:  ₨11,125.13
฿3,647.70
List Price:  ฿5,106.92
You save:  ฿1,459.22
₺3,232.12
List Price:  ₺4,525.11
You save:  ₺1,292.98
B$499.21
List Price:  B$698.91
You save:  B$199.70
R1,908.54
List Price:  R2,672.04
You save:  R763.49
Лв180.65
List Price:  Лв252.92
You save:  Лв72.26
₩135,197.71
List Price:  ₩189,282.20
You save:  ₩54,084.49
₪368.63
List Price:  ₪516.10
You save:  ₪147.47
₱5,633.91
List Price:  ₱7,887.71
You save:  ₱2,253.79
¥15,144.47
List Price:  ¥21,202.86
You save:  ¥6,058.39
MX$1,659.40
List Price:  MX$2,323.22
You save:  MX$663.82
QR364.31
List Price:  QR510.04
You save:  QR145.73
P1,370.91
List Price:  P1,919.33
You save:  P548.42
KSh13,148.68
List Price:  KSh18,408.68
You save:  KSh5,260
E£4,729.52
List Price:  E£6,621.52
You save:  E£1,892
ብር5,680.63
List Price:  ብር7,953.11
You save:  ብር2,272.48
Kz83,612.74
List Price:  Kz117,061.18
You save:  Kz33,448.44
CLP$97,978.20
List Price:  CLP$137,173.40
You save:  CLP$39,195.20
CN¥722.95
List Price:  CN¥1,012.16
You save:  CN¥289.21
RD$5,921.50
List Price:  RD$8,290.34
You save:  RD$2,368.83
DA13,490.83
List Price:  DA18,887.70
You save:  DA5,396.87
FJ$226.12
List Price:  FJ$316.58
You save:  FJ$90.46
Q779.86
List Price:  Q1,091.83
You save:  Q311.97
GY$20,923.51
List Price:  GY$29,293.76
You save:  GY$8,370.24
ISK kr13,946.60
List Price:  ISK kr19,525.80
You save:  ISK kr5,579.20
DH1,013.19
List Price:  DH1,418.51
You save:  DH405.32
L1,763.34
List Price:  L2,468.75
You save:  L705.40
ден5,702.11
List Price:  ден7,983.18
You save:  ден2,281.07
MOP$805.89
List Price:  MOP$1,128.28
You save:  MOP$322.39
N$1,893.44
List Price:  N$2,650.90
You save:  N$757.45
C$3,681.15
List Price:  C$5,153.75
You save:  C$1,472.60
रु13,335.63
List Price:  रु18,670.42
You save:  रु5,334.78
S/370.84
List Price:  S/519.19
You save:  S/148.35
K382.72
List Price:  K535.82
You save:  K153.10
SAR375
List Price:  SAR525.01
You save:  SAR150.01
ZK2,522.76
List Price:  ZK3,531.96
You save:  ZK1,009.20
L461.43
List Price:  L646.02
You save:  L184.59
Kč2,350.75
List Price:  Kč3,291.15
You save:  Kč940.39
Ft36,729.02
List Price:  Ft51,422.10
You save:  Ft14,693.08
SEK kr1,071.30
List Price:  SEK kr1,499.86
You save:  SEK kr428.56
ARS$85,766.82
List Price:  ARS$120,076.98
You save:  ARS$34,310.16
Bs691.04
List Price:  Bs967.48
You save:  Bs276.44
COP$387,583.68
List Price:  COP$542,632.66
You save:  COP$155,048.97
₡50,832.34
List Price:  ₡71,167.31
You save:  ₡20,334.97
L2,468.78
List Price:  L3,456.40
You save:  L987.61
₲737,805.73
List Price:  ₲1,032,957.54
You save:  ₲295,151.80
$U3,781.90
List Price:  $U5,294.82
You save:  $U1,512.91
zł400.73
List Price:  zł561.05
You save:  zł160.31
Already have an account? Log In

Transcript

Welcome back everyone. In this video Our goal is to add the events and write a script to get our player shooting off a fireball. Exciting times. All right, we're going to start off in our project settings here. So jump up to your main toolbar, come under Settings, project settings, and select input along the left hand side, we're going to add a new action mapping at the very top. Let's click this plus button next to action mapping not access mapping action mapping, and we're going to name this black magic.

And we're going to bind two events or two not not events, two buttons to this event. The first one we're going to bind to this is going to be the num one key on the keyboard. The second one that I am going to bind to To make this event happen is going to be our game, pad trigger. gamepad right to trigger that's what I'm looking forward game pad right trigger. So if you got a gamepad that will fire this event off as well. Okay, so with that done, we can exit out of our project settings.

And next we're going to be doing some work inside of our BP player. So come to this directory content Metroidvania blueprints, characters, double click on your BP player to open her up. And in the My Blueprint panel, we're going to add a new graph. So we've currently got a graph for our move set. This is things like our movement, input, jump, landing, back, dash, etc. I want to have a separate graph for our black magic.

So in the graph section, let's add a new graph. Let's call it black magic And it's already open. So let's see what we can add to it. Let's start off with right clicking and adding our black magic events our action event that we just created. So the first thing we want to do after we press this button is we want to check if we've got our black magic actually slot in. Now this is working a little bit ahead.

Upcoming here in a little bit, we're going to be working on putting together a black magic selection menu so you can slot what black magic that you have active and available for use, you're not gonna be able to use all your different black magic like your electro spark and your fireball. At the same time. You can only use one of those when you press the white the right trigger button. So we need to find out which black magic Do we have slotted or that on our HUD that is available to us and we have Have a variable that's going to be storing this information. And our list of variables is getting quite lengthy here, under our player info category, we've got this be magic slotted, okay, we're going to drag that into our graph. If you remember right, we are going to be slotting array over here, we're going to be changing out what is slotted based on the menu screen that we're about to be building a little bit later on.

And we are going to drag out of this in type in switch on IE be magic so when we press the right trigger or the one button we're going to find out what black magic do we currently have slotted into our HUD and based on which one we do, we can do something. In this case we're concerned about the fireball. So we want to kick off some script to shoot out a fireball. A little bit down below this I'm going to right click and create a custom events Add Custom Event. And I'm gonna call this use fireball all caps. Sure.

Now with this Custom Event created, I can call this custom event from here, so I'm just going to type in use fireball. So this is essentially a wireless signal when we press the one button or the right trigger button we're going to see see if black magic slotted is fireball if it is we're going to send a wireless signal to tell this custom event to fire off. The reason I'm using a wireless signal here is because it's just gonna keep our graph a little bit cleaner here. I'm going to left click and drag around this tap the C key call this use black magic for that bit of script. And now I'm going to move our use fireball off to the right here because we're going to be building a lot more script for the time being because we do Want to shoot off a fireball here before the end of the video I'm going to change our be magic slotted I'm going to manually set this to be fireball here too.

If you want to make this instance editable while we're playing the game, let's just change that right there you set that to be instance editable. So while we're playing, we can change that up. Okay, so what do we want to do when we use the firewall? Well, first thing we need to do is we need to check Do we have enough manner to actually use the magic and it's a good thing we created a function for that in the last video, so let's drag and drop this function into the graph. We need to check Do we have enough mana to use this magic now? We need to input our magic attributes here.

So in our magic black fireball category, we've got fireball attributes. Let's plug this right in here. Now if you remember right, this fireball attributes struck at contains information about how much manna does it cost to use this. And in this function that we created the last video here it is check if enough magic to manna to use magic. The attributes that we just plugged in here we're going to break them apart, we're going to find out what their manna cost is. And if it is less than our current manna, we're going to say yes, we have enough manna let's fire off a fireball.

Okay, so we know we're going to need a branch node here. So let's keep the flow of execution going and put in a branch node. Now, checking to see if we have enough man is just one of the things that I want to check. So let's drag off of our enough manna and type in and we're going to bring in an and Boolean because there's three things that we want to see that are true before we're going to allow a fireball to be fired off. So do we have enough manna? That's one Second thing I want to find out is, is our fireball ready to be fired off by default it is.

So we're going to drag and drop that on this pin. Then I'm going to click the Add pin button to add another input over here and the thing that I want to check as well is if we are in missed form or not now we have not scripted anything related to miss yet, but this is kind of working ahead to make sure that this works when this course is all said and done. We're going to bring in this B is using Miss. We're going to get that and we're going to drag off of this and type in the word not. So if we are not in this form, and if our fireballs ready, and if we have enough manna if all three of those are true, then we're going to fire off the fireball more that to come. But if it's not true, what I'm going to do is I'm going to play a sound play a sound 2d And the sound that I want to play is going to be V R and negative Q, that one right there.

This is in your engine content. So if you don't see this particular sound effect, you can come under view options, check show engine content, it should be available for you. So we've got that v r negative Q. And you know what I'm going to right click on this pin, and I'm going to promote this to a variable. Over in our blueprint panel, I'm going to call this s FX. You insufficient manna, even though there could be a multitude of reasons why we were not able to cast this, I'm just going to call it that for now.

My insufficient man of sound, and I'm going to create a brand new category for this in case I want to use it later. And this will be let's call this our magic general category. There we go. And when we promoted that to a variable, it automatically populated that variable with the VR negative cue that we had slotted into this node right here. Okay, so all this is optional. You don't have to play the sound effects.

But I think it's nice to have. Okay, so if this is true, if this all evaluates to true, I want to bring in our function for updating of manna, we want update our manna like so. And I want to bring in doo doo doo doo doo our fireball attributes. plug this into our update manner, like so. And if you remember, update manna function was doing this. We're taking whatever attributes we're plugging in, in this case, it's the fireball attributes.

We're breaking our our attributes in To the manage costs and we're going to be subtracting our manna from our current to update our manna amount. Okay, so after we update the manna, we're going to bring in our be used fireball, drag and drop that in, we're going to set it and we are going to say yes, our player is now using the fireball. Remember, we're using some of these variables to drive our animations. So that's what that one's going to be used for. Then we're going to set our be fireball ready, drag and drop that into the graph, we're gonna set that and we're gonna say it's not ready right now, meaning you can't cast another one right now. You only can cast this one for the time being, then let's bring in a sequence node.

I'm going to hold down the S key, left click to bring in a sequence node. We're gonna make two things happen here. First thing I'm going to break In a delay node hold down the d dS and Dan key and left click we're going to do a short delay in fact I'm going to make this a 10th of a second point one seconds then I am going to spawn actor from class. The actor I want to spawn is going to be our BP fireball that we just created. There is our BP fireball make sure that BP fireball and not the skill be magic fireball BP fireball. Then we need to feed this a transform.

Where do we want to spawn this from? Well, we created a fireball spawn point. So let's left click and drag that in from our components panel. Then off of this, we can drag off and let's get the world transform. And this orange output can be plugged into the spawn transform input of that node. Then what I want to do is I want to play a Sound, play sound at location.

What sound do I want to play? Well, we just imported a sound called fire ball. It is this SF x fireball. Which location do we want to play it at? Well, why don't we play it at the location of our fireball spawn points, I'm going to drag off here again and say get world location. Yellow output means I can plug that into the yellow input.

And then I'm going to set our B use fireball. We're going to set that and remember earlier, we'd set this to true. Well, after we fire off the fireball, we're going to set this back to false. Okay, again, that's to drive some animations for our character that's to come yet. Okay, so off of this a sequence no then then one branch. Won't, I'm going to break off a wire here and we're going to bring in another delay node.

And the delay I want to set this duration for is going to be our fireball cool down, like so. And when this is done, we're gonna say the fireball is ready to be, we're gonna set this we're gonna set this to true again. So remember our fireball cooldown is going to be 1.13 seconds and after that has expired, we're going to say yes, our character can fire off the fireball once again. Okay, so with all this script done, let me just highlight it here to kind of show you what we got here. Maybe you can pause the video here to see the first part and here is the second part that's enlarge that a little bit. Okay, I am going to left click and drag, tap the C key and I'll call this a shoot.

Fireball something like that. Now let's Compile and Save and moment of truth you're testing this out now note, a fireball should appear but the proper anims won't be working yet and there will be no character exertion, noisy yet not a character exertion noise you should hear, you know, fireball shooting out so let's give this a try. Okay, so I need to be sure that I interact with the right Dyess here. Well actually I don't have to because in the upper right, you can see that I've already got the fireball slotted But anyways, let's pretend I've got to interact with that get the skill. Okay, now, tap the one key and you can see that Ball is shooting out. If I turn this way, shooting out and look in the upper right, you can see that my man account is actually decreasing as well as I fire it out.

So if I spam the one key really fast, you'll notice that you're hearing that kind of rejection sound. And that's because in the script, if our fireball is not ready, and I'm trying to spam that button, it's basically saying, hey, you can't use it right now. One of these things is evaluating to be false. Okay, so again, if you tried to test that out, no, it wasn't working. Make sure you got your be magic slotted here, temporarily set to fireball. And we can also test this out live in game.

If I do shift in f1. I'm going to grab my window right here. Let me jump back to the main level editor. Here's my BP player. Now let me go be magic slotted remember, I made this instance this variable instance variable I'm gonna set it now to be electrical spark so now I don't have fireball slot it in. Let me bring my play window once again and you can see in the upper right here I've got electro sparks slotted in and now if I try casting fireball nothing will happen even if I you know collect this fireball skill which I don't need to do right now nothing's going to happen however shift in f1 I changed my be magic slotted back to fireball I will be able to fire that off again I hit the Escape key.

Well, long story short, you will be able to fire it out again. Guys. I think the point is proven. We've gotten a fireball shooting out. So happy, happy day. All right, let's get on to some animations next.

That'll do it all for this one. We will see you 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.