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
€94.79
List Price:  €132.71
You save:  €37.92
£78.97
List Price:  £110.56
You save:  £31.59
CA$139.89
List Price:  CA$195.85
You save:  CA$55.96
A$153.73
List Price:  A$215.23
You save:  A$61.50
S$134.32
List Price:  S$188.05
You save:  S$53.73
HK$778.26
List Price:  HK$1,089.59
You save:  HK$311.33
CHF 88.57
List Price:  CHF 124
You save:  CHF 35.43
NOK kr1,105.08
List Price:  NOK kr1,547.16
You save:  NOK kr442.07
DKK kr706.99
List Price:  DKK kr989.82
You save:  DKK kr282.82
NZ$170.06
List Price:  NZ$238.10
You save:  NZ$68.03
د.إ367.26
List Price:  د.إ514.17
You save:  د.إ146.91
৳11,906.24
List Price:  ৳16,669.22
You save:  ৳4,762.97
₹8,436.24
List Price:  ₹11,811.08
You save:  ₹3,374.83
RM447.10
List Price:  RM625.96
You save:  RM178.86
₦167,464.25
List Price:  ₦234,456.65
You save:  ₦66,992.40
₨27,687.73
List Price:  ₨38,763.93
You save:  ₨11,076.20
฿3,470.35
List Price:  ฿4,858.63
You save:  ฿1,388.28
₺3,445.98
List Price:  ₺4,824.51
You save:  ₺1,378.53
B$578.68
List Price:  B$810.17
You save:  B$231.49
R1,810.53
List Price:  R2,534.81
You save:  R724.28
Лв185.34
List Price:  Лв259.49
You save:  Лв74.14
₩139,691.42
List Price:  ₩195,573.58
You save:  ₩55,882.15
₪373.67
List Price:  ₪523.15
You save:  ₪149.48
₱5,901.36
List Price:  ₱8,262.14
You save:  ₱2,360.78
¥15,574.86
List Price:  ¥21,805.43
You save:  ¥6,230.57
MX$2,020.46
List Price:  MX$2,828.72
You save:  MX$808.26
QR363.35
List Price:  QR508.71
You save:  QR145.35
P1,355.53
List Price:  P1,897.79
You save:  P542.26
KSh12,948.70
List Price:  KSh18,128.70
You save:  KSh5,180
E£4,969.50
List Price:  E£6,957.50
You save:  E£1,988
ብር12,262.61
List Price:  ብር17,168.15
You save:  ብር4,905.53
Kz91,256.94
List Price:  Kz127,763.36
You save:  Kz36,506.42
CLP$97,119.28
List Price:  CLP$135,970.88
You save:  CLP$38,851.60
CN¥724.58
List Price:  CN¥1,014.45
You save:  CN¥289.86
RD$6,000.34
List Price:  RD$8,400.72
You save:  RD$2,400.37
DA13,341.73
List Price:  DA18,678.95
You save:  DA5,337.22
FJ$227.04
List Price:  FJ$317.87
You save:  FJ$90.82
Q769.16
List Price:  Q1,076.85
You save:  Q307.69
GY$20,834.51
List Price:  GY$29,169.15
You save:  GY$8,334.63
ISK kr13,772.62
List Price:  ISK kr19,282.22
You save:  ISK kr5,509.60
DH995.44
List Price:  DH1,393.66
You save:  DH398.21
L1,819.82
List Price:  L2,547.83
You save:  L728
ден5,825.40
List Price:  ден8,155.79
You save:  ден2,330.39
MOP$798.74
List Price:  MOP$1,118.27
You save:  MOP$319.52
N$1,801.35
List Price:  N$2,521.97
You save:  N$720.61
C$3,666.61
List Price:  C$5,133.40
You save:  C$1,466.79
रु13,462.23
List Price:  रु18,847.67
You save:  रु5,385.43
S/378.10
List Price:  S/529.35
You save:  S/151.25
K400.90
List Price:  K561.28
You save:  K160.37
SAR375.38
List Price:  SAR525.55
You save:  SAR150.16
ZK2,752.36
List Price:  ZK3,853.42
You save:  ZK1,101.05
L471.69
List Price:  L660.38
You save:  L188.69
Kč2,395.79
List Price:  Kč3,354.20
You save:  Kč958.41
Ft38,840.72
List Price:  Ft54,378.57
You save:  Ft15,537.84
SEK kr1,099.74
List Price:  SEK kr1,539.68
You save:  SEK kr439.94
ARS$100,165.56
List Price:  ARS$140,235.79
You save:  ARS$40,070.23
Bs690.96
List Price:  Bs967.37
You save:  Bs276.41
COP$440,690.82
List Price:  COP$616,984.78
You save:  COP$176,293.95
₡50,645.88
List Price:  ₡70,906.26
You save:  ₡20,260.37
L2,517.41
List Price:  L3,524.47
You save:  L1,007.06
₲775,966.15
List Price:  ₲1,086,383.66
You save:  ₲310,417.50
$U4,274.58
List Price:  $U5,984.58
You save:  $U1,710
zł411.21
List Price:  zł575.71
You save:  zł164.50
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.