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
€96.03
List Price:  €134.44
You save:  €38.41
£78.97
List Price:  £110.57
You save:  £31.59
CA$143.92
List Price:  CA$201.50
You save:  CA$57.57
A$160.15
List Price:  A$224.22
You save:  A$64.06
S$135.90
List Price:  S$190.26
You save:  S$54.36
HK$776.95
List Price:  HK$1,087.76
You save:  HK$310.81
CHF 89.61
List Price:  CHF 125.46
You save:  CHF 35.85
NOK kr1,132.24
List Price:  NOK kr1,585.18
You save:  NOK kr452.94
DKK kr716.48
List Price:  DKK kr1,003.10
You save:  DKK kr286.62
NZ$176.72
List Price:  NZ$247.41
You save:  NZ$70.69
د.إ367.25
List Price:  د.إ514.17
You save:  د.إ146.91
৳11,949.45
List Price:  ৳16,729.71
You save:  ৳4,780.25
₹8,504.71
List Price:  ₹11,906.93
You save:  ₹3,402.22
RM450.50
List Price:  RM630.72
You save:  RM180.22
₦155,597.43
List Price:  ₦217,842.63
You save:  ₦62,245.20
₨27,817.89
List Price:  ₨38,946.16
You save:  ₨11,128.27
฿3,454.30
List Price:  ฿4,836.16
You save:  ฿1,381.86
₺3,507.24
List Price:  ₺4,910.28
You save:  ₺1,403.03
B$630.94
List Price:  B$883.35
You save:  B$252.40
R1,822.81
List Price:  R2,552.01
You save:  R729.20
Лв187.70
List Price:  Лв262.78
You save:  Лв75.08
₩144,917.66
List Price:  ₩202,890.52
You save:  ₩57,972.86
₪361.94
List Price:  ₪506.74
You save:  ₪144.79
₱5,900.06
List Price:  ₱8,260.32
You save:  ₱2,360.26
¥15,702.92
List Price:  ¥21,984.72
You save:  ¥6,281.80
MX$2,038.30
List Price:  MX$2,853.70
You save:  MX$815.40
QR368.69
List Price:  QR516.19
You save:  QR147.49
P1,365.11
List Price:  P1,911.21
You save:  P546.09
KSh12,923.70
List Price:  KSh18,093.70
You save:  KSh5,170
E£5,089.47
List Price:  E£7,125.47
You save:  E£2,035.99
ብር12,635.69
List Price:  ብር17,690.47
You save:  ብር5,054.78
Kz91,513.08
List Price:  Kz128,121.98
You save:  Kz36,608.89
CLP$99,000
List Price:  CLP$138,603.96
You save:  CLP$39,603.96
CN¥729.57
List Price:  CN¥1,021.43
You save:  CN¥291.86
RD$6,083.32
List Price:  RD$8,516.89
You save:  RD$2,433.57
DA13,417.46
List Price:  DA18,784.98
You save:  DA5,367.52
FJ$231.78
List Price:  FJ$324.51
You save:  FJ$92.72
Q770.27
List Price:  Q1,078.41
You save:  Q308.14
GY$20,904.88
List Price:  GY$29,267.67
You save:  GY$8,362.78
ISK kr13,874.61
List Price:  ISK kr19,425.01
You save:  ISK kr5,550.40
DH998.53
List Price:  DH1,397.99
You save:  DH399.45
L1,842.29
List Price:  L2,579.28
You save:  L736.99
ден5,908.76
List Price:  ден8,272.50
You save:  ден2,363.74
MOP$800.37
List Price:  MOP$1,120.56
You save:  MOP$320.18
N$1,804.90
List Price:  N$2,526.94
You save:  N$722.03
C$3,679.90
List Price:  C$5,152.01
You save:  C$1,472.10
रु13,596.02
List Price:  रु19,034.98
You save:  रु5,438.95
S/373.62
List Price:  S/523.08
You save:  S/149.46
K405.04
List Price:  K567.08
You save:  K162.03
SAR375.67
List Price:  SAR525.96
You save:  SAR150.28
ZK2,767.31
List Price:  ZK3,874.34
You save:  ZK1,107.03
L477.70
List Price:  L668.80
You save:  L191.10
Kč2,412.77
List Price:  Kč3,377.98
You save:  Kč965.20
Ft39,808.32
List Price:  Ft55,733.24
You save:  Ft15,924.92
SEK kr1,103.71
List Price:  SEK kr1,545.23
You save:  SEK kr441.52
ARS$102,213.30
List Price:  ARS$143,102.71
You save:  ARS$40,889.41
Bs690.92
List Price:  Bs967.31
You save:  Bs276.39
COP$438,077.06
List Price:  COP$613,325.41
You save:  COP$175,248.35
₡50,326.04
List Price:  ₡70,458.47
You save:  ₡20,132.42
L2,538.30
List Price:  L3,553.73
You save:  L1,015.42
₲780,569.17
List Price:  ₲1,092,828.06
You save:  ₲312,258.89
$U4,458.42
List Price:  $U6,241.97
You save:  $U1,783.54
zł409.45
List Price:  zł573.24
You save:  zł163.79
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.