Welcome back everyone we are on to the good stuff. In this one we will be doing some BP scripting in our parent target. The goal in this one will be to create some variables and functions that all children targets are going to inherit. And we'll start by creating the script for a child target who is labeled as a stand alone target. Now, we have some targets that we are intending to spawn up as either part of a set or individually. So this first part, we're going to be dealing with what we want to do, how we're going to spawn up a single target if that's all we want is one standalone target.
So let's find your way over to the blueprints actors folder and double click on your BP target parent. And right away we're going to create three variables in here. The first one will be called points that we want to change to And integer because we want to score some points when we shoot this. Let's create another variable this one will be called lifetime. How long is our target going to stay alive active out there in the world before it just disappears. I'm going to change this to a float variable one with a decimal point we'll add a another variable and this one will be called his stand alone.
Target question mark. And we will change that to a Boolean type. We want to flag any of our targets as either a standalone target or not. Go ahead and compile from here and we want to change a few more things about our variables here is standalone target that is selected first. By default, let's leave this unchecked. But we do want to make this instance editable.
So go ahead and check that then select your lifetime. Let's set a default lifetime of 10 seconds. And let's make this instance editable too. So we have fine control over how long each target stays alive. Lastly, select your points, let's set a default point value of 100. And let's also make this instance editable.
Okay? With that in place, we can now do some scripting. And by default, you should have an event right here in your Event Graph called Event Begin Play. I deleted mine out before I started this video, so I'm going to manually add it back in. And I can do that by right clicking, doing a search for Begin Play. And right there, that's the guy I want.
So upon beginning play, what do we want to do? Well, I want to do a check for our standalone target. So let's bring it over reference to our standalone target we want to get it off of this I'm going to drag out a wire and do a search for a branch node. And I want to find out if any of our targets here are labeled as a standalone target. Now remember, this is our parent target, all children will inherit these properties down here. So is it a standalone target.
Next, I want to bring in references to our target. That is the actual disc shaped thing that represents what we want to shoot our point value and our spotlights. And out of any three of these, it doesn't matter. You can drag out a wire and type in set visibility. And we can plug all three of these into the target and what we want to do here is out of the true brand And we want to set our visibility to not be visible. So what we've got is about upon beginning play we're going to check is the target labeled as a standalone target.
If it's true, we want to hide the target the point value in the spotlight. Also, what we want to do is bring in a reference to our target collision. Drag a wire out of it and type in set collision enabled that guy, and we want this to be labeled as no collision. So here's a look at that script for you. So here's the deal if it is labeled as a stand alone target, and I'm just going to jump on over to our viewport. We don't want this disk shaped thing visible.
We don't want our numerical point value visible We don't want the spotlight to be shining, we don't want that visible at all. And our target collision, this thing encapsulating our entire target, we don't want that to have any collision either, because this target is actually going to exist out in the world for just the player to overlap the trigger volume, which will then tell it to spawn. We don't want the player to accidentally see this trigger this target rather, or even to be able to shoot it. So that is why we are saying if this target is labeled as a standalone target, we don't even want to see it. And we don't even want the collision to be enabled. We will deal with the rest of it in just a little bit here.
So that's all well and good.