Skill Acquire - Script #1

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.72
List Price:  €129.81
You save:  €37.09
£79.26
List Price:  £110.97
You save:  £31.71
CA$135.49
List Price:  CA$189.69
You save:  CA$54.20
A$153.49
List Price:  A$214.89
You save:  A$61.40
S$134.92
List Price:  S$188.90
You save:  S$53.97
HK$782.50
List Price:  HK$1,095.53
You save:  HK$313.03
CHF 90.16
List Price:  CHF 126.23
You save:  CHF 36.07
NOK kr1,085.06
List Price:  NOK kr1,519.13
You save:  NOK kr434.06
DKK kr691.90
List Price:  DKK kr968.69
You save:  DKK kr276.78
NZ$167.41
List Price:  NZ$234.39
You save:  NZ$66.97
د.إ367.19
List Price:  د.إ514.08
You save:  د.إ146.89
৳10,980.73
List Price:  ৳15,373.46
You save:  ৳4,392.73
₹8,335.04
List Price:  ₹11,669.39
You save:  ₹3,334.35
RM472.40
List Price:  RM661.38
You save:  RM188.98
₦139,532.04
List Price:  ₦195,350.44
You save:  ₦55,818.40
₨27,813.53
List Price:  ₨38,940.06
You save:  ₨11,126.52
฿3,638.31
List Price:  ฿5,093.78
You save:  ฿1,455.47
₺3,237.16
List Price:  ₺4,532.16
You save:  ₺1,294.99
B$501.53
List Price:  B$702.17
You save:  B$200.63
R1,888.66
List Price:  R2,644.21
You save:  R755.54
Лв180.76
List Price:  Лв253.07
You save:  Лв72.31
₩134,741.70
List Price:  ₩188,643.77
You save:  ₩53,902.07
₪367.71
List Price:  ₪514.81
You save:  ₪147.10
₱5,617.33
List Price:  ₱7,864.49
You save:  ₱2,247.16
¥15,132.45
List Price:  ¥21,186.03
You save:  ¥6,053.58
MX$1,658.17
List Price:  MX$2,321.51
You save:  MX$663.33
QR364.88
List Price:  QR510.84
You save:  QR145.96
P1,378.06
List Price:  P1,929.34
You save:  P551.28
KSh13,256.67
List Price:  KSh18,559.87
You save:  KSh5,303.20
E£4,744.14
List Price:  E£6,641.99
You save:  E£1,897.84
ብር5,687.29
List Price:  ብር7,962.44
You save:  ብር2,275.14
Kz83,433.85
List Price:  Kz116,810.73
You save:  Kz33,376.88
CLP$98,290.17
List Price:  CLP$137,610.17
You save:  CLP$39,320
CN¥722.08
List Price:  CN¥1,010.95
You save:  CN¥288.86
RD$5,924.54
List Price:  RD$8,294.60
You save:  RD$2,370.05
DA13,479.97
List Price:  DA18,872.49
You save:  DA5,392.52
FJ$225.66
List Price:  FJ$315.94
You save:  FJ$90.27
Q780.13
List Price:  Q1,092.22
You save:  Q312.08
GY$20,949.30
List Price:  GY$29,329.86
You save:  GY$8,380.56
ISK kr13,941.60
List Price:  ISK kr19,518.80
You save:  ISK kr5,577.20
DH1,013.74
List Price:  DH1,419.27
You save:  DH405.53
L1,764.37
List Price:  L2,470.19
You save:  L705.82
ден5,702.11
List Price:  ден7,983.18
You save:  ден2,281.07
MOP$806.29
List Price:  MOP$1,128.85
You save:  MOP$322.55
N$1,909.24
List Price:  N$2,673.01
You save:  N$763.77
C$3,682.20
List Price:  C$5,155.22
You save:  C$1,473.02
रु13,347.49
List Price:  रु18,687.02
You save:  रु5,339.53
S/372.08
List Price:  S/520.93
You save:  S/148.85
K382.87
List Price:  K536.04
You save:  K153.16
SAR375.15
List Price:  SAR525.22
You save:  SAR150.07
ZK2,481.24
List Price:  ZK3,473.83
You save:  ZK992.59
L460.94
List Price:  L645.33
You save:  L184.39
Kč2,346.52
List Price:  Kč3,285.22
You save:  Kč938.70
Ft36,532.34
List Price:  Ft51,146.74
You save:  Ft14,614.40
SEK kr1,069.05
List Price:  SEK kr1,496.71
You save:  SEK kr427.66
ARS$85,802.56
List Price:  ARS$120,127.02
You save:  ARS$34,324.45
Bs691.35
List Price:  Bs967.92
You save:  Bs276.56
COP$386,901.39
List Price:  COP$541,677.43
You save:  COP$154,776.03
₡50,320.66
List Price:  ₡70,450.94
You save:  ₡20,130.27
L2,469.73
List Price:  L3,457.73
You save:  L987.99
₲739,686.52
List Price:  ₲1,035,590.72
You save:  ₲295,904.20
$U3,756.16
List Price:  $U5,258.77
You save:  $U1,502.61
zł399
List Price:  zł558.62
You save:  zł159.61
Already have an account? Log In

Transcript

Welcome back everyone. Well, we are at a point now where we've got a lot of pieces in place. We've got these skill diocese that we've created earlier that we want our player to interact with to then collect a skill. And then upon collecting the skill, we want that Widget Blueprint that we've just been working on to appear on the screen saying, hey, you've collected the fireball ability. This is how you use it, right? Well, what we don't have in place is some script to a present a message to our player that hey, you can collect this skill, you're within range of this Dyess to collect that skill, and B, we don't have any interaction system to even check for if you are within range and press a button to collect that skill.

So let's take care of that now. Now, there's a lot of script that's going to go into this but we're going to take this piece by piece, and we're going to start off here by going into our practice. Project Settings and you can find your project settings across your main toolbar here, you got a settings button. And you want to go into project settings right here. And over along the left hand side, you've got a section called input. And we have some action mappings.

Over on the left hand side. Well currently we have one action mapping one for the jumping action. What you can do here is you can create an event and bind it to some buttons right here in your action mappings. So I want to create a new one, we have one here for jump by default, I'm going to click this plus button and I'm going to create a new action mapping and I'm going to rename it right here and call it inter act. And then what do I want to bind this event know to Well, I want to bind it to let's see gamepad. If I do a search for gamepad face button, right?

Base button right? I'm using an Xbox One controller so for me that's going to be the B button. But if you're using like a PlayStation controller know that that's the circle button gamepad face button right? And I also want a another button to fire off the interact event here. So I'm going to click this plus button. And right here I am going to do a search for right not gamepad the keyboard events.

Keyboard, right? So that's my right arrow key. That's what that is. So if you just do a search for right once again, I was under the keyboard section, the right that's the right arrow key. Okay. So we have created an event called interact and it will be fired off whenever we press a gamepad.

The face button right which is the B button on the Xbox controller or the right key on a keyboard. That is my Up, down, left, right arrows, okay, you can bind it to any sort of key that you want. Okay, so we're all good with that. Next thing I need to do is I need to jump into my BP player. This is the folder directory on how to get there. Double click on your BP player.

And we're going to create a couple of more variables inside of our BP player. I know we've got a lot of them already, but come underneath your blueprint panel variables click plus variable, we're going to create one called be can inter inter act question mark. We do want this to be a boolean variable. And I am going to compile this right away. I'm going to set a new category for this I'm going to left click drag overwrite this category and we're going to create one called inter act tooltip for this surely Leave a tooltip this will say, sets true or sets to true when overlapping and interact double object use to show our interaction message. Okay.

And by default, I do want this to be false. You can see we've got a new category called interact down here. Okay, one more variable I want to create, click this plus variable button. I'm going to be calling this one, interact trace length. And I'm going to change this variable type by clicking this little pill right next to it. I'm going to change that to be an integer.

You could have also changed it right up here. I'm going to change the category here to be interactive. And I'm going to compile this. So I can set a default value here to be 100. What essentially we're going to be aiming to do here is if I jump over to my viewport tab is we're going to basically shoot out an invisible line, well, we're actually going to check out a debug line. And we're going to check, it's going to shoot out from our character here, our capital component, and it's going to check to see if it hit anything.

And if it did, we're going to make stuff happen. So that's the idea here and we're going to utilize this interact trace length variable to help with that. Okay, next, what we're going to do is we are going to jump on over to our event graph here inside of our BP player. Let's find some empty space. And we created that interact event before so I'm going to simply right click, do a search for interact and there is my action event for interact and again, this will be fired off whenever I press the beach buttons on my Xbox controller or the right arrow key. Okay, so what I want to do is off of the press, I'm going to do a search for line trace by channel.

There's a function for that. And what this is going to do is it's going to send out a laser beam of sorts to check to see if it hit anything, I got to give it a start and an end point. So what I'm going to do is I'm going to grab a reference to my capsule component. And I'm going to drag out a here the capsule component and say get world location. And I'm going to feed that is the starting point for my line trace. And you're actually going to get to see this line trace in just a little bit here.

Okay, so now I need to feed this in end point but to help with this, I need to drag off of my capsule components. I need to get in The forward vector that is which direction is forward. Then off of this, I want to multiply this by our interact trace length. Okay, get interact trace length. So I am then going to drag off of the return value here, type in multiply, we're looking for vector times int. So you got one yellow input, one green input, and then gonna move this over to the right here.

I'm going to drag off of our world location of our capital component. And I'm going to hit the plus symbol, and I'm going to be looking for vector plus vector. So that's going to go into here and the forward vector times 100 here is going to go here, and then I'm going to take that and plug that into the end point. So our line is going to start at our capital component. And then we're going to shoot it off out into the distance 100 unreal units, and that's going to be our ending point. So it's going to be a rather short line trace.

Now the visibility channel here is what I've got set as our trace channel. Now, if I go way, way back from earlier in the course, I'm gonna hop on over to my content browser here briefly. I'm gonna come under blueprint actors, you don't have to do this. This is just for me to show you this but we created this BP interactive base object interactive object base from which our skill blueprints derive from by double click on this to open it up. We have an interact collider here. And if I come underneath the collision section, we have a trace response for visibility.

It is going to block our visibility channels so we want that to be blocked so that we can do something Stuff whenever we shoot out a line trace, and this interact, collider is going to block it and basically detect that. Hey, line trace hit me along our visibility channel. Okay? All right, so trace channel is visibility. What else I want to do draw debug type, I want to set this to be for duration. This is going to enable us to actually see this line trace out in the world, which I think you're really gonna want.

So you can see the extent as to how far that line reaches out into the world. Okay, in fact, we should be able to just Compile and Save, and I can play right now and if I hit the B button or my right arrow key, you can see that red line kind of emanating from my character's position, right? It's very faint, very hard to see. But the idea here is that we're going to use that red line to see if we are interested With this Dyess Okay, so so far so good. With that little bit done, it might be good idea to compile in save. And so the next thing we need to do here is to create an intermediary of sorts to be able to communicate from our BP player here to our various skill blueprints those diocese.

So how we're going to do that is we are going to create something known as a Blueprint Interface. There's lots of ways to communicate between blueprints in Unreal Engine four. And I'm not going to get into all of them. That's a little bit outside of the scope of this video, but we're going to be using one of those forms of communication, a Blueprint Interface to communicate from our BP player to our various skill blueprints. So I'm going to jump back to the main level editor here. And I am going to go into my Metroidvania Blueprints folder and inside of here, I'm going to go into the next miscellaneous or misc folder.

It's currently empty. Inside of here, I'm going to right click, come under the blueprints section. And in this little flyout menu, we've got something called a Blueprint Interface, select this. And I'm going to simply call this BP AI for Blueprint Interface underscore interact. That I'm going to double click on this to open it up. And what we can do with ins inside of here is create a brand new function that we can use to call from one blueprint RBP player blueprints and then receive it in another blueprint.

So we've got this new function zero right over here, I'm just gonna simply rename this one. You can add a new one, but it had one here waiting for us. So simply click on that hit f2 and rename it we're gonna call this one object interacted with. And that's literally it. That's all we need to do here, we don't need to do anything in the graph down here, we don't need to add any inputs or outputs. Just Compile and Save this.

Next, what I need to do is I need to tell both of our BP player blueprints. And the other one we want to select is our BP interactive object base located in this folder. We need to tell both of those blueprints to add that Blueprint Interface. So make sure you've got your BP player and your BP interactive object base open. I'm just going to place them side by side. And right now I've got my BP interactive object base.

If you come into the class settings, over on the right hand side, it's asking for implement interfaces implemented blueprint interfaces. Currently there's nothing, we're gonna add one. And we can add this BPI interact that we just created. So again all of our different skill dices here, like these guys right here, they all inherit from this BP interactive object base, which is why I am adding our Blueprint Interface on the base instead of save this specific BP skill double jump, because it will now inherit it. If I go ahead and Compile and Save and then for example, jump into my BP skill double jump. Let's open the full Blueprint Editor here.

This inherits from BP skill base, which in turn inherits from BP interactive object base class. And if I was to go into the class settings here you can see that there is an inherited in interface of BPI interact. So you can see how that all pieces together. Okay, so I added our BPI interactive, or interact rather inside of our interactive object base. There it is, I need to do so in our BP player as well. So select that guy.

Go into your class settings and over on the right hand side, implemented interfaces. Let's add one and let's add our BPI interact and Compile and Save that guy that was necessary for this next part of script that we're going to add here in our Event Graph. So after we do this line trace, we are going to drag out of this out hit and we're going to do a search for break hit result. So after it hits something, you can grab a lot of goodness out of this out hits To tell you things like what did you hit, where did you hit etc. So we're going to break that hit result open. And before we drag off of here I'm going to drag off of our execution wire right here and I'm going to bring in a branch node.

And the thing that I want to evaluate the condition is can we interact this Boolean variable that we just created so drag and drop that on top of the condition. So we are going to set if we can interact with this particular skill blueprint inside of our various skill dies is here so like inside of our BP skill, double jump, we will be able to set inside of here if we can actually interact with it or not. So that's to come. So we're kind of laying some groundwork for what's to come. Okay. So we're gonna say if we can interact with them.

We're then going to do a another check off of our true branch here is is valid Kind of this question mark looking guy right here and we want to find out if the hit actor, the actor that we hit with our line trace if that is a valid object, this is just kind of a safety check of sorts to prevent any messages from appearing in case that is not a valid object. Okay, so if it is a valid object, then what we want to do is drag out of our hit actor one more time, and we're going to do a search for object interacted with. So we will find when we drag out of our hit actor, this BPI interact, object interacted with and in parentheses, it says message, okay, and it should have this little envelope icon on it and it should say target either BPI interact, okay.

Now note, if I was to simply right click in some empty space here and just do a search for object interacted with. I've got different versions here I've got this call function object interacted with, where it says target is BP player. And that is different from interacted can barely spell today. Interact object interacted with this BPI interacted object with interface call. So note that we've got two three different variations here. You'll want this one with the envelope here.

This is the one that's going to be able to send a message over to our skill diocese that hey, did we interact with you and if so, we're gonna make something happen. Okay. So, we have set the groundwork here for in an interaction of sorts here between our BP player and our skill diocese. We've got plenty of more work to do, but that's going to be a wrap on this one. I'm going to finish this off by jumping into our BP player, left clicking and dragging around all the script hitting the C key. And I'm gonna call this our interact script.

Gonna Compile and Save. One more time. Guys. That'll do it all for this one more work to be done. We'll see you in the next video.

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.