All right, welcome back everyone in this video we are going to continue scripting our parent target, there is still more work to do. We created some script to spawn a target. If it's labeled as a standalone target, we still need to add some script to still spawn the target if it's not a standalone target, and we also need to add some script to destroy the target when shot because currently, our projectiles do nothing. So without further ado, come back into your content first project blueprints actor's folder. And if you don't already have it open up, double click on your BP target parents. Just some quick notes from what I have done since the last video.
This is a script that we created in the last videos. And all I did here is I added some common box around certain sections just to make it a Little bit more clear as to what each section does. So just to recap here, this is a script off of the Event Begin Play. And I just added a little comment box and you can get one of these by left clicking and dragging around a series of nodes, and then tapping the C key after you drag out a marquee selection. C as in Charlie. So I just added a comment box right here saying that this standalone target is to hide target and remove the collision if it is a standalone target.
Then coming back down here a little ways. We've got our spawning of a standalone target. And I've just commented this section of the script right here. And then off to the right, I added another comment box for the actual spawning of the target. This is where the spawn animation happens. And I created these comment boxes specifically for certain purposes because later on in this video, I'm actually going to hook in a wire off of this false branch.
Okay, so I just kind of wanted to make clear what each section of our script was doing. Okay, firstly, we did make it so that if it is a standalone target, we are actually spawning in the target. Well, what if it is not a standalone target? What if this is false? Well, we actually still need to spawn in the target. So I'm going to drag a wire off of this and plug it into our sequence node down here, so that we can still spawn in our target.
Remember off the true branch up here, we were just setting the visibility of our target and disabling the collision. And if it was a standalone target, then we were doing this bit of script, which was making it visible and enabling its collision. again. So up here, we're basically saying, hey, if it's not a standalone target, we don't really care about the setting of the visibility and the setting of the collision enabled, just go ahead and spawn that target. And this is all going to make a little bit more sense when we get the additional set spawner blueprint scripted as well. We'll come back here and just to recap at, get all the pieces sort of in line so you can see how it's all working.
So make sure off of this Event Begin Play is standalone target are the false branch we are saying, even if it's not a standalone target, we want to spawn in that target with this bit of script down here. So that's simple enough, right? Let's go ahead and create the scripting of destroying our target. So this is going to involve us interacting with this target collision, knock the trigger volume. So come under your target color. component let's right click, and let's add an event.
The event we want to add is on component begin overlap can The first thing we're going to do is out of this other actor we want to detect. If our projectile is the thing is overlapping that target collision so drag a wire out of here and we will do a cast to projectile. First Person projectile to be precise. And if I jump out of this blueprint for just a moment and go back to my editor, in our First Person BEP folder, we've got a Blueprints folder inside of there. You can see we've got a first person Character Blueprint, and we've also got a first person projectile blueprint. This is the thing we want to check if that is overlapping.
Our target collision which is This circular bit of collision right here, so no projectiles are overlapping that we want something to happen. And this is where we are checking Was it the first person projectile and if it was we want to do something and if not, you could do something out of here. But what we want to do next is dragon wire out of the edges first person projectile and simply type in destroy actor. Here we are saying if it was the first person projectile that was overlapping the target collision, we want to destroy the first person projectile. You don't want that to just cut right on through. We want to destroy it once that overlaps.
Next thing we want to do is spawn any jmeter so drag a wire off of here and do a search for spawn emitter. at location. What emitter do we want to spawn in you can choose whichever one you like but there is a handy dandy explosion P under explosion that is found in this Starter Content. That is great for that. And I'm going to scale this explosion up a little bit in the x, y and z. I'm going to make it a little bit bigger by changing this to be 1.5 in the x, the Y in the Z. And now I need to specify what location do we want to play this explosion at?
Well, I'm gonna drag out a reference to my target collision here. Drag and drop that. And then out of this I want to drag out a wire and say gets world location and we can plug this into the location. So then we are saying when the first person projectile overlaps that target collision, we want to destroy the target our First Person projectile and we want to spawn an explosion at our target collisions location. And we're going to scale it up a little bit in size. Now anytime you have an emitter, you probably want to have a sound to go with it.
So let's drag a wire out of here to keep our execution going and type in. Let's do a place down at location. And we've got an explosion emitter. So let's do an explosion cue sound. And it's also asking for where should this sound be located? Well, we've got our target collision location right here.
So let's just drag a wire out here and plug that into the location up here as well. Double clicking on this wire will add a little reroute nodes so you can kind of bend your wire around like this and keep your script looking nice and clean. And we're almost finished up here. Next thing I want to do is drag a wire out of here and I'm going to do a short delay real short delay This delay is going to be I'm going to set it to be point 05 seconds. And then after that I am going to say drag out a wire destroy actor. So the reason I am bringing out a little delay here before we destroy the actor, which is this target because our target is self is because if we don't add this delay and we shoot a target, almost immediately upon its spawning, you will get some warnings.
And through some testing that I've done, this delay will get rid of that warning. So this is a little bit of a safety check prevents an error if shooting a target before the animation is finished. So with that bit of script right there, let me just try to frame it up for you. We can put a marquee selection around this guy, left click, drag, tap that C key and around this We'll just make a comment to call this let's see, destroy, projectile and targets. When hits. I'll go ahead and Compile and Save this.
And then moment of truth, let's just jump in and play this f open F to open little damage and my target should be able to shoot and destroy this file and boom, it is gone. So we know this is all working right here. Now this part that we just did up here where we took a wire out of this false branch and plugged it into our target spawn. This we can't actually test yet until we do our, our scripting for our blueprint, target spawner. That'll come in a couple videos time. And I will circle back to this I promise.
Anyways, that is gonna do it all for this one guys. We will see you in the next video.