‫Hello and welcome back.
‫Now we're ready to create a projectile class.
‫Now our tanks and our towers need to fire projectiles, which means that we're going to need a C++ class
‫for the projectile.
‫Now, the projectile is going to need its own static mesh so that we can see the projectile once we
‫spawn it in the world.
‫So we're going to create the C++ class and then we'll create a blueprint based on this class.
‫And this is going to be a challenge for you since these are all things that you already know how to
‫do.
‫So you're going to create a new C++ class and choose the correct parent class.
‫Now, the projectile doesn't need to handle any user input, so that should tell you right there that
‫this is not going to be a --.
‫Now, once you've done this, add a static mesh variable just like we've done for our other classes,
‫construct it in the constructor using create default sub object and set the static mesh as the root
‫component.
‫Now once you're done, go ahead and create a blueprint based on this projectile class.
‫And in the blueprint, set the static mesh property for the static mesh component.
‫Pause the video and create the projectile class now.
‫Okay.
‫So we're ready to create the projectile C++ class.
‫So I'm going to go to file new C++ class.
‫And because we don't need user input, this is just going to be a basic actor.
‫An actor can be placed in the world or spawned in the world, and we're going to be spawning these in
‫the world.
‫So we need to derive from the actor class.
‫I'm going to click next and name this new class.
‫Now this is a projectile.
‫So I think projectile is a perfect name for this.
‫I'm going to leave it in the same folder as all our other C++ classes and click Create Class.
‫So here we have projectile FX and projectile CP and we need to add a static mesh variable.
‫So I'm going to add a private section just under the protected one.
‫So private and we're going to need a U static mesh component.
‫So this would be a U static mesh component.
‫It's going to be a pointer.
‫Now, that's okay.
‫If you named it something different, I'm going to call this projectile mesh.
‫Now we're going to expose this using you property.
‫So you property.
‫And I'd like to be able to edit this from the default blueprint.
‫So I think edit defaults only is appropriate for this.
‫I'm going to give it a category and the category can be combat.
‫It's not really important what we call it, and that's all the exposure I'm going to give this variable.
‫That's okay if you have different you property settings here.
‫Now we need to construct this.
‫So let's go into projectile CP into the constructor and say projectile mesh and we're going to call
‫create default sub object using u static mesh component.
‫And for the text, I'm just going to say projectile mesh.
‫And finally, we need to set this to be the root component.
‫So I'm going to say root component equals projectile mesh and I'm going to spell it correctly there.
‫Okay.
‫So that takes care of the C++ side of things.
‫Now, you may not have thought of this, but we have this primary actor tic b can never tic equals true.
‫And because our projectile doesn't really need to tic, we can set this to fall.
‫So if you'd like, go ahead and set that to false along with me here.
‫And we do get the red squiggles here under the assignment operator.
‫And this is simply because we need to include the header file for you static mesh components.
‫So if we go to based upon CP, we can see that header file here because we needed to include it for
‫the static mesh components in the base pod.
‫So I'm going to steal that, include and paste it right here at the top.
‫And that way you a static mesh component is defined.
‫Now let's go ahead and compile this and I'm back here in the editor and the next thing we need to do
‫is create a blueprint based on projectile.
‫Now I'm going to go into the blueprints folder and we have a pawns folder.
‫I'd like to create a new folder and call this actors because our projectile is not a pawn, so it doesn't
‫really need to go into the pawns folder.
‫So we have a new actors folder.
‫I'm going to go into it and this time I can right click and select Blueprint Class and here we can select
‫the class to base this blueprint on.
‫If we click the dropdown next to all classes, then we can search for projectile and there is the projectile
‫class.
‫So I'm going to select that click select.
‫And now we have a new blueprint based on the projectile class.
‫So that's another way to create a blueprint based on one of our C++ classes.
‫Now I'm going to call this B.P. underscore projectile and I'm going to double click to open up Beep
‫Projectile and I'll click Open Full Blueprint Editor.
‫If you see that, go ahead and click on it.
‫And we have our blueprint and here's projectile mesh.
‫And by default it doesn't have its static mesh property set.
‫So we're going to set that and I'm going to choose the SM projectile.
‫I'm sure that is what you selected for your projectile.
‫Makes sense.
‫So we have a projectile.
‫Excellent.
‫I'm going to compile and save this close out of it and click save all just to make sure everything is
‫saved and we now have a projectile.
‫So in summary, you have created your projectile class and you created a blueprint based on projectile
‫and gave it a use static mesh component variable.
‫And in the blueprint you set it's static mesh.
‫So now we have a projectile to work with.
‫We're ready to start spawning these things and we're going to take care of that in the next video.
‫I'll see you soon.