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
€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. 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.