‫Okay.
‫So we'd like to see an explosion when one of the pawns dies.
‫So if I destroy a tower here, there's the explosion.
‫And if the tower destroys me, I can boom, blow up.
‫Welcome back.
‫Now, we've been implementing some special effects, and the next special effect we'd like to implement
‫are some hit particles that will cause an explosion.
‫On death, this means death for the tower or death for the tank.
‫So since this will be implemented for each pawn, inheritance should come to mind.
‫So for these death particles, let's form a game plan.
‫First, we need to add a new particle system pointer, and we're going to add this to the base pond
‫class because we'd like the explosion effect to happen when either the tank or the tower gets destroyed.
‫Next, we're going to spawn an emitter on death.
‫Now, the base pawn class has its own version of handle destruction, and that's called in both the
‫tank and the tower using super.
‫So because this is implemented in base pawn, whatever we put in this function in based pawn will happen
‫for the tank and the tower.
‫So we know how to spawn emitters at location using new gameplay statics.
‫So that should be pretty easy.
‫Now the last thing will be to set the particle system in blueprints and we have a p underscore death
‫effect particle system that we can set this to, which means our particle system pointer needs to be
‫exposed with U property and set to be editable, whether it's edit anywhere or edit defaults only.
‫And these are all things that you have experience doing.
‫So this is going to be your challenge.
‫Add the particle system variable.
‫Add this to base pawn because we want to inherit this functionality in the tank and the tower next spawn
‫the emitter we saw that handle destruction in the base pawn class is the perfect place to do this.
‫And next you're going to set the particle system in blueprints since you're going to make this particle
‫system variable exposed to the blueprint editor.
‫So pause the video and implement death particles on your own now.
‫Okay.
‫So let's go into the base -- header file and we can add a new particle system variable.
‫This is going to be private and it's going to be forward declared and the type will be you particle
‫system pointer.
‫And I'm going to call this death particles.
‫Now, we need to expose this so we can set it from the blueprint editor.
‫So I'm going to make this a U property edit anywhere category and I'm just going to place this in combat.
‫There we go.
‫So now we're going to have a particle system and we need to spawn this and handle destruction.
‫So let's go to base upon CP and find handle destruction.
‫And here it is.
‫We even have a To-Do here that says visual and sound effects.
‫So we're taking care of visual effects right now.
‫Now spawn emitter at location is a gameplay statics function.
‫So we need gameplay statics here.
‫And I remember just from doing this so much that it's in kismet slash gameplay statics.
‫Now we also need the proper include for a U particle system.
‫So here's my documentation.
‫It's open and I'm going to search for you particle system and here is you particle system and I can
‫scroll down to the include and it's particles slash particle system dot h so I'm going to include that
‫as well.
‫And now I can call spawn emitter at location using U gameplay statics spawn emitter at location.
‫Now we saw that with the overload we used before.
‫We could use this for a world context object and next we needed to pass in a particle system.
‫And for this we have death particles.
‫So I'm going to pass that in death particles.
‫Next, we need a location and for the base pond I'm going to pass and get actor location and for the
‫rotation, get actor rotation.
‫And it's as simple as that.
‫Now before I compile, I'd like to check to make sure death particles is not a null pointer.
‫So I'm going to first check to see if death particles, if that is valid, then I'm going to call spawn
‫emitter at location.
‫So I'm going to move that just inside my if check and now I'm going to compile.
‫Okay.
‫So I'm back here in the editor and the next thing to do is I need to go and set this particle system
‫in my blueprints both for the pawn and the turret.
‫So I'm going to open up BP pawn tank.
‫And here in the combat section I have death particles.
‫And before I set it, I'm going to go into the assets and effects folder and check out Death Effect,
‫and we can see that it looks like a cool little explosion.
‫So I'm going to set that.
‫So let's go back into BP Pond Tank.
‫Here's the combat section.
‫Remember, I have BP Pond Tank self selected to see these variables and here's death particles and I'm
‫going to select p underscore death effect and I'll compile save and close that.
‫Now that takes care of the death effect for when the tank dies, but we also need to set it for the
‫tower.
‫So let's go into ponds, open BP pond, turret, and here's the combat section, here's death particles.
‫Let's click the dropdown and select death effect.
‫Now we can compile, save and close out of that and we're ready to test this out.
‫I'm going to go to a second viewport by going to Window Viewport Viewport two, and here's a nice full
‫screen viewport for me.
‫I'm going to hit alt p and that will start the game for me.
‫So now I'm ready to start the game and I'm going to try to first destroy a couple of these towers.
‫So let's boom.
‫There we go.
‫I did it.
‫And I'm going to go ahead and destroy another one.
‫And let's see if the towers can destroy me.
‫Boehme and I lost.
‫Excellent.
‫So in summary, we now have death particles, which is a nice explosion that occurs when one of the
‫ponds dies.
‫We're making great progress and we're almost done with this section.
‫I'll see you in the next video.