BP Scripting - Target Spawner #1

15 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
€93.41
List Price:  €130.79
You save:  €37.37
£79.90
List Price:  £111.86
You save:  £31.96
CA$137.16
List Price:  CA$192.03
You save:  CA$54.87
A$153.08
List Price:  A$214.33
You save:  A$61.24
S$135.90
List Price:  S$190.27
You save:  S$54.36
HK$781.66
List Price:  HK$1,094.36
You save:  HK$312.69
CHF 91.23
List Price:  CHF 127.73
You save:  CHF 36.49
NOK kr1,107.76
List Price:  NOK kr1,550.92
You save:  NOK kr443.15
DKK kr696.86
List Price:  DKK kr975.63
You save:  DKK kr278.77
NZ$168.60
List Price:  NZ$236.05
You save:  NZ$67.44
د.إ367.24
List Price:  د.إ514.16
You save:  د.إ146.91
৳10,972.60
List Price:  ৳15,362.09
You save:  ৳4,389.48
₹8,346.11
List Price:  ₹11,684.89
You save:  ₹3,338.77
RM475.54
List Price:  RM665.78
You save:  RM190.23
₦123,487.65
List Price:  ₦172,887.65
You save:  ₦49,400
₨27,846.85
List Price:  ₨38,986.71
You save:  ₨11,139.85
฿3,694.58
List Price:  ฿5,172.56
You save:  ฿1,477.98
₺3,236.41
List Price:  ₺4,531.11
You save:  ₺1,294.69
B$519.35
List Price:  B$727.11
You save:  B$207.76
R1,861
List Price:  R2,605.48
You save:  R744.47
Лв182.73
List Price:  Лв255.83
You save:  Лв73.10
₩137,535.16
List Price:  ₩192,554.72
You save:  ₩55,019.56
₪374.71
List Price:  ₪524.61
You save:  ₪149.90
₱5,763.02
List Price:  ₱8,068.46
You save:  ₱2,305.43
¥15,525.12
List Price:  ¥21,735.79
You save:  ¥6,210.67
MX$1,695.96
List Price:  MX$2,374.42
You save:  MX$678.45
QR364.20
List Price:  QR509.89
You save:  QR145.69
P1,420.18
List Price:  P1,988.32
You save:  P568.13
KSh13,372.99
List Price:  KSh18,722.73
You save:  KSh5,349.73
E£4,798.26
List Price:  E£6,717.75
You save:  E£1,919.49
ብር5,719.92
List Price:  ብር8,008.12
You save:  ብር2,288.20
Kz83,641.63
List Price:  Kz117,101.63
You save:  Kz33,460
CLP$96,028.39
List Price:  CLP$134,443.59
You save:  CLP$38,415.20
CN¥723.89
List Price:  CN¥1,013.48
You save:  CN¥289.58
RD$5,819.58
List Price:  RD$8,147.64
You save:  RD$2,328.06
DA13,455.35
List Price:  DA18,838.03
You save:  DA5,382.68
FJ$226.17
List Price:  FJ$316.65
You save:  FJ$90.48
Q777.12
List Price:  Q1,088.01
You save:  Q310.88
GY$20,929.88
List Price:  GY$29,302.67
You save:  GY$8,372.79
ISK kr14,022.59
List Price:  ISK kr19,632.19
You save:  ISK kr5,609.60
DH1,011.06
List Price:  DH1,415.53
You save:  DH404.46
L1,768.33
List Price:  L2,475.73
You save:  L707.40
ден5,750.59
List Price:  ден8,051.06
You save:  ден2,300.46
MOP$805.69
List Price:  MOP$1,128
You save:  MOP$322.31
N$1,863.42
List Price:  N$2,608.86
You save:  N$745.44
C$3,672.13
List Price:  C$5,141.13
You save:  C$1,469
रु13,425.24
List Price:  रु18,795.88
You save:  रु5,370.63
S/376.35
List Price:  S/526.91
You save:  S/150.55
K385.89
List Price:  K540.26
You save:  K154.37
SAR375.01
List Price:  SAR525.03
You save:  SAR150.02
ZK2,677.10
List Price:  ZK3,748.04
You save:  ZK1,070.94
L464.84
List Price:  L650.79
You save:  L185.95
Kč2,347.91
List Price:  Kč3,287.17
You save:  Kč939.26
Ft36,370.18
List Price:  Ft50,919.71
You save:  Ft14,549.52
SEK kr1,092.76
List Price:  SEK kr1,529.91
You save:  SEK kr437.15
ARS$87,614.14
List Price:  ARS$122,663.30
You save:  ARS$35,049.16
Bs690.85
List Price:  Bs967.22
You save:  Bs276.36
COP$390,329.27
List Price:  COP$546,476.60
You save:  COP$156,147.32
₡51,017.42
List Price:  ₡71,426.43
You save:  ₡20,409.01
L2,476.75
List Price:  L3,467.55
You save:  L990.79
₲749,236.02
List Price:  ₲1,048,960.40
You save:  ₲299,724.38
$U3,833.15
List Price:  $U5,366.56
You save:  $U1,533.41
zł404.64
List Price:  zł566.52
You save:  zł161.87
Already have an account? Log In

Transcript

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.

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.