Welcome back everyone. In this video, we will be adding a variable and creating a script needed to make our health pick up, heal the player. Now I've done a little work between videos here shaping up my level and I actually do I have a BP health pickup in my level. Now if I just tap the two key on my keyboard, I am going to fly right to where it is in my level. And I have a kind of in the back of this corner over here and you may be saying initially, how did I just snap to where that was immediately? Well, something I should mention, and I should have mentioned in the gray boxing process is you can set some locational bookmarks throughout your level.
If you hit Ctrl plus a number key, wherever your cameras located, that will set a bookmark for your camera too. So you can fly to that location immediately. For example, right over here. I set control posts to as my bookmark with my camera placed right about here so I can be anywhere else in my level like way over here tap the two key and it'll fly me right to it. So you've got up to 10 bookmarks control plus one control plus two control plus three, etc. And then after you set those bookmarks, all you need to do is just tap the corresponding number key to fly right to it.
Alright, let's get back on topic here. What do we need to do? First thing come in your blueprint actor's folder, double click on your BP health pickup. And right away we will create a new variable. This one will be called player health to add finally adding some health. Let's change the variable type here to a float right away.
And then I will compile so that we can add in a default value. I'll go 20 And we will also make this instance editable too. So in the event, you do want to make it so that some of your health pickups give you more health than others, you can do that, you know, maybe you can scale some down and they'll give you 10 points at health and maybe you scale some to be a little bit bigger and they gave you, you know, 30 points of help that kind of thing. So again, just to reiterate what this does, if I Compile and Save, and I select my health pickup in my level, you can see right there is my player health to add that I can customize for every one of these I drag out into my level. Okay, so with that done, we just need to do the scripting end of it.
I'm going to left click and delete these default event nodes. And what I'm going to do is find my collision up here in the components panel, right click, add an event for on component begin overlap. Now, we only want to trigger if it is us the first person character that is overlapping it so let's drag out of this other actor and do a cast to first person character again when you overlap this volume when something does it will output some information. And it'll I'll put it through this other actor. And right here we are doing a check to see if it is the first person character will do something right here. If it's not, you can do something out of the cast failed.
All right, next, let's drag out of the as first character because we want to call this function the update health function that we created within our First Person Character Blueprint. How much health do we want to add or subtract? Well, that is simple enough. We'll grab our player health to add this drag and drop it onto there like that. And then let's drag away out of here, and let's play a sound. So let's look for a play sound to D node.
And I do have a sound in mind it is called v r underscore, open Q. And of course you can slot in whatever sound you are happy with. Then lastly, I'm going to drag a wire off of this and say destroy actor. And the target here is self. So basically what this is saying kind of backing things up here is saying that once we overlap this collision volume with our First Person character, we're going to update our target our First Person character's health by how much by 20. Then we're going to play a sound and then we are going to destroy who, ourselves the target here is self.
So with that, I'm just going to drag a marquee selection by left clicking and dragging tap that seeking And I'll call this restore health. Let's Compile and Save. I'm just gonna jump into my level let's back up a little bit. I have added some hazards since the last video. So let's play from here. I added some steam right over here Actually, let me jump in from the getting of the level so you can see what I've all created so far between videos gonna jump in and play.
So this is the very beginning of my level. A little bit more work to be done for sure. But there's my open pit of doom right there. I did get hit by that fan twice. After open this is some steam so it'll damage me so look in the upper left of my viewport. And you can see I now have 40 health.
I have this conveniently placed elevator to hoist me on up to that Health pickup. I'll jump on over and you can see I now have 60 health. So that did in fact work and you heard the sound effect as well. Alright guys, we now have our health pickup scripted that is gonna do it all for this one. We will see you in the next one.