Welcome one welcome all In this video, we are going to be adding the script and variables for our be P targets set spawner. This guy within our blueprint actors folder right now we've currently got some targets that we can overlap a volume, and they can spring up individually. But wouldn't it be nice if we could have a whole set of targets three, four or five spring up at about the same time. So that's what we're going to accomplish in this one. So if you haven't already done so go ahead and double click on your BP targets set spawner to open it up. And we're going to build some script first and as we go along, we will build out the variables needed.
So let's think about what we want to have happen here. If I click on over my viewport tab, we created this trigger volume and we want to make it so that one In our character is overlapping this trigger volume, we spawn us up some targets at these given spawn target locations that I have indicated by these arrow components. Okay, so that's our goal here and jumping over to our Event Graph. The first thing we are going to do is right click on our trigger volume. And we will add an event for on component begin overlap. And we want to do something when it is our character overlapping that so drag out of the other actor and do a cast to first person character.
And now this next node is important. We only want something to happen the very first time we overlap this trigger volume. So drag out of here and do a search for a do once node because we don't want targets to spring up if they overlap it again and again. And then off of this, I am going to drag off a wire and bring in a sequence node. And there is this plus button to add a pin, I want to add three more of these. I have over in my components panel specified spots for five targets to spawn up in with this particular set spawner.
I am going to specify five targets to spawn and Now note that after we're done building this out, you can choose to have three targets one in 10, targets 20, however many you want. And I think it'll become pretty obvious on how to do that. Once we build out this initial set spawner that's going to bring in five targets. Okay, so then off of our sequence node here, we're going to drag out a wire and we're going to do a search for a delay node. The idea here is is that once our First Person Character begins to overlap the trigger volume, we're going to spawn in five targets, 1234 and five. And I want to have a slight delay between them.
Now note that you could spawn them all in at the same time. But I want to build this to be a super flexible system and give you the designer as much flexibility as you want when setting these up in your level, and you'll see that come to fruition here in just a moment. So what kind of delayed we want on this? Well, how about we save this out to a variable, what I can do here is drag out of this pin are actually not drag out, we can right click on this pin and do something called Promote to Variable. When we do this, we're going to add a variable to our components panel down here and you can see that we've already got a float variable of this variable type that lime green equals float variable hanging and plugged into our delay node. So I'm going to give this a name I'm gonna call it targets underscore oh one underscore delay.
How long do I want to delay before I spawn in target number one, just going to Nestle that down here. And something else I want to do is I want to click this button right here to get that eyeball to show to make this instance editable. And again, if you'll remember, if I drag my BP targets set spawner into my level, let me just drag and drop it in here. And I do want to rotate this around. I think I'm gonna put this way down here kind of at the bottom of this, this river area I have fiddled with the overall layout some of my level and I've essentially got this sort of river of sorts and a little bit downhill section. Okay, so I'll drop it down somewhere in there, right?
And notice that with that selected over in the Details panel, well, I've first have to Compile and Save once I Compile and Save, then over in the Details panel, with that BP set spawner selected, we now have access to set our target o one delay right here in the level editor. Okay, so we're gonna have a little bit of a delay, what are we going to do after that delay? Well, we're going to drag out a wire and type in spawn actor. From class, we want to spawn in some type of actor. And well, if I pick from this drop down here, I could say, Hey, bring in BP target 100. We could do that.
However, I want to build this system as flexible as possible. So what I'm also going to do here is right click on this purple pin. We're going to promote this to a variable I'm going to call this target underscore, oh one. And if I compile here, and save, of course, it's gonna complain about a spawn transform, which I do need to do. And I will fix that in just a moment here. But after I compile, I can then set a target defaults.
And you can set some defaults in here. In fact, why don't we just make it so that by default, we spawn in BP target 100. Remember, our variable type here is a class. It's an actor class blueprint. Remember, we created some BP targets from the blueprint actor class. So when we right clicked here, to promote this to a variable, we created a new variable of the type actor so we need to give them is a spawn transform and you remember that we created all these arrow components to specify locations where we can spawn these in.
So let's bring in spawn target oh one from our components panel, just drag it in here, then drag a wire off of this and type in get world location. rather not world location, I want to get world transform. Transform is going to give us not only locational data, but rotational data as well, which is part of the reason. coming over to my viewport that I rotated these arrows to be facing toward the direction that I'm expecting our player to be entering into this trigger volume. That is good because when they enter in there, I want those targets to spring that location and be facing the player Okay, so this is just one target. Now, the neat thing is, is that we can duplicate a lot of this code here and plug it into sequence, then one, then two, then three, then four, etc.
And all we got to do is swap out our variables. Now I do want to make this target oh one instance editable as well. So let me just check this instance editable box, which is the same thing as clicking on this eyeball down here as well. And again, if I Compile and Save, come back into my Level Blueprint. Now I can see with that actor selected, I can now customize this target spawner to have the delay of my choosing, and which target do I want. So now the rest of the system is pretty easy to build out.
All I've got to do is duplicate all these variables, several So let me just start with target oh one delay, and I'm just going to right click Duplicate. I'm going to call this target Oh to delay, right click, duplicate target, oh three delay, right click Duplicate, target both for delay and I'll try to make this as fast as possible. Duplicate target Oh, five delay. And this is worth noting as well, you can move these variables around in your stack so I can put all the delays together by simply dragging them like so. It's kind of handy. Then I got my target.
Oh one let's duplicate this several times. Now you're not going to be able to duplicate this one like this. So you know what, because we need to duplicate this This several times as well this chunk of script, let me get this into place. First I'm gonna left click drag out a marquee selection, I'm going to Ctrl C to copy this Ctrl V to paste once, twice, three times and four times and you can hook in your then one to that one, then two to this one, then three to this one, and then four to this one. Now, what I need to do here is swap out some of the variables Okay, so this is target oh one which I'm going to just left click drag out a marquee selection, tap that C key and just mark this as target one. Here, this is going to be target two, so I don't want the target One delay I want the target o to delay which I can get by simply dragging and dropping like so.
Instead of target old one, I'm gonna delete that, right click right here promote this to a variable and call this surrogate underscore oh two. I'll set the defaults for these at the very end here. And I don't want spawn target oh one for my target oh two I want spawn target location. Or rather transform Oh to left click drag sikhi you know, call that target to. Just gonna create a little bit more room here. This can get a little bit crowded for swapping Out target Oh threes delay I'm just going to show another technique that you can do here you can right click on this guy and you can see in your right click menu you can replace with another like variable we already have target oh three delay created.
So this is a possibility to swap out the variable like this. You can only do that if you have that variable already created. Target old one, we don't want that one. I'm going to right click on this class, Promote to Variable and I will call this target underscore oh three. swap out my spawn target oh one with spawn, target three. Left click drag see key.
And we'll call this target three. Then let's come down to target four. I will right click on this delay replace with target oh four Get rid of this target right click on this pin right here to Promote to Variable target oh four not spawn target oh one but spawn target oh four we can drag and drop that right on their left click drag marquee selection see key target for in the last one here right click Replace with target old five delay not target oh one, but rather right click Promote to Variable target underscore old five and we want this to be at spawn target. oh five let's left click drag out a marquee selection C key and call this target get five let's compile really quickly here. And I do want to set some default values for all these so for target oh one delay I do want this to be zero seconds just straight up zero seconds target Oh to delay.
I want to set this to be point two which it already is target oh three I want this to be point four second delay. Target oh four. This is going to be a point six second delay. Target oh five. This is going to be a point eight second delay. You may find some other values that you want for this.
And the great thing is you're going to be able to customize this per blueprint target set spotter. I just want a small delay between each target in my set that spawns up my target oh one. I do want this to set. Set it to me target. bp target 100 target oh two. I will set this to be the same for the time being I'll set the defaults for all these to be that target over 100 points.
I will make this instance editable as I will with all the rest of these instance editable target oh five. This will also be the hundred point targets. And I will check that great let's Compile and Save this one more time.