‫Hey, welcome back.
‫In the last video, we created our capsule component, and we set it to be the root.
‫In this video, we need to add some more components.
‫Specifically, we need some meshes for the base and the turret part of our tank.
‫And we also need a projectile spawn point, as we've discussed in previous lectures.
‫So let's hop into VS code.
‫Now here in Base Pancake, we have our capsule component.
‫We can add our other components in this private section just below it.
‫So for our meshes we want to use you static mesh component.
‫And of course these will be pointers as this isn't a base type and the first mesh I'm going to call
‫base mesh and just like capsule comp base mesh will get its own you property macro.
‫Now notice you static mesh component is not giving me an error for not forward declaring it.
‫That's because you static mesh component is included by default in all actors and of course pawns are
‫actors, so it has used static mesh component.
‫Now if you're wondering how to know which types are included by default and which are not, you can
‫always try to compile and see if you get an error.
‫We know what the error looks like when you fail to include a header that you need.
‫Another approach would be to always forward declare and always include header files for unreal engine
‫types have include guards that prevent them from being included multiple times in a single file.
‫In fact, the very header we're in has one of these.
‫It's called Prague WMA once.
‫So anyway, we have our base mesh and we'd like another static mesh component.
‫So this will be a U static mesh component pointer and this will be for the turret.
‫So I'm going to call this turret mesh and just like base mesh, it will also get a U property macro.
‫So now that we have our base mesh and turret mesh pointers, it's time to actually construct these.
‫So let's head over to Base Pont CP and do that in the constructor here.
‫So first we're going to say base mesh and we'll assign this the value returned by create default sub
‫object.
‫Now before I fill it in, why don't you go ahead and type in the correct type here?
‫That's right.
‫It's you static mesh component.
‫Now for the name, we're going to use the text macro and we can call this base mesh.
‫Now it's important that we attach base mesh to something, since we'd like the mesh to follow the capsule
‫component around.
‫As we're moving the PON, we're going to attach it to the root.
‫So base mesh has a function called setup attachment and setup attachment takes a seen component to attach
‫to.
‫We're going to attach base mesh to capsule comp.
‫We could easily have past root component in here.
‫Now we're going to create the turret mesh in the same way.
‫So turret mesh equals create default sub object and this will also be a use static mesh component.
‫And for the name for this one, we'll call this turret mesh.
‫Now we mentioned previously that we'd like the turret mesh to be attached to base mesh so we can say
‫turret mesh set up attachment and the component will attach it to will be base mesh.
‫So we'll pass base mesh and as the argument so where does setup attachment come from?
‫If we right click and go to definition, we'll see that it's a function here in scene component.
‫So all scene components have this function.
‫So we'll close out of scene component.
‫Now you're probably noticing the IntelliSense errors saying pointer to incomplete class type.
‫This is actually another false error.
‫And that extension we downloaded doesn't actually fix this, but this compiles just fine, so we don't
‫need to worry about it.
‫Now, if it's bothering you, you could just add the include include components slash static mesh component
‫and that'll get rid of those red squiggles.
‫And as I mentioned, these have include guards so they won't be included twice.
‫So that's up to you.
‫I'll go ahead and leave the include here just so we don't get those squiggles.
‫So now that we have our base mesh in our turret mesh, the only thing left is our projectile spawn point.
‫So this will be your challenge.
‫Create a pointer called projectile spawn point.
‫Choose the correct type that's appropriate for a projectile spawn point and give it a name using the
‫text macro and create default sub object.
‫Attach the projectile spawn point to the turret mesh.
‫And a question I want you to think about is do we need to include its header file, pause the video
‫and create this component now?
‫All right.
‫So let's add this next component.
‫Now, the projectile spawn point will be a U seen component, and we'll call this projectile spawn point.
‫Now we'll add a you property macro.
‫That's okay.
‫If you didn't do this, if you didn't just go ahead and add the you property macro now, now let's go
‫to Base Pond CP and construct this component.
‫So we're going to say projectile spawn point and create default sub object.
‫And this will be a you seen component.
‫Now, you probably gave this an awesome name.
‫I'm just going to call it Spawn point and we need to set up the attachment for this.
‫So we're going to say projectile spawn point, set up attachment and will attach this to turret mesh
‫and there we go so we can compile this, make sure everything compiles successfully and we have a successful
‫compile.
‫So everything's looking great.
‫So in this video we created static mesh components and we saw that we didn't need to include the headers
‫for those.
‫They were already included by default.
‫We also created a scene component called projectile spawn point and our code compiled just fine without
‫including the header for that as well.
‫We'll be creating a blueprint based on our base pond C++ class very soon.
‫I'll see you in the next video.