‫In this lecture, we're going to create a C++ class.
‫Now we need a class that we can use for our pawns.
‫Now I'm saying pawns, plural, because there will be two different pawns in our game.
‫There's going to be the tank that we use to roll around the level, and there's going to be a turret
‫which will be our enemy so we can create a base pawn class.
‫And this is going to have the basic functionality that both the tank and the turret will share.
‫And this way we can create our two child classes, the tank and the turret.
‫So these are going to inherit qualities from the base pawn class and these are things that both pawns
‫are going to share, such as having the mesh, having a capsule component and the ability to launch
‫projectiles.
‫Now, we're going to get into all those features in future videos for this video.
‫We're just going to create the C++ class and add some basic variables to it.
‫So this is our motivation for creating our first C++ class.
‫Now we're ready to start creating some C++ classes for this project.
‫Now you'll see down here in the content browser that there are no folders for C++ classes.
‫That's because we haven't created any just yet, but we're about to write now so we can go up to tools
‫and select new C++ class.
‫And here is where we're going to choose the parent class for the class that we're going to create.
‫And by default, we have several options here to choose from.
‫This is something that you should have seen in previous lectures.
‫So now we have some decisions to make here.
‫For one, which parent class are we going to choose?
‫We have.
‫The first one is none.
‫That would basically allow us to create a plain old C++ class, but we're going to need some extra functionality.
‫For one, we want to be able to place an instance of this object in the world.
‫So we can't do that with a plain old C++ class.
‫We could do that with a character or a pawn or an actor, but which one of these is most appropriate
‫for what we want to do?
‫Well, we need to take a step back and think about what exactly we're trying to create here.
‫We're trying to create a tank that we can control and move around the level and shoot projectiles so
‫that we can cause damage and all that good stuff in our assets folder.
‫Just to remind us, we have this meshes folder here and we have the tank base and we have the tank turret.
‫These are two different meshes that are going to be in our class.
‫And so we need the capability to have meshes.
‫And so a plain C++ class does not have that ability.
‫So let's think about this for a second.
‫What parent class should we use?
‫Well, the first class that should probably come to your mind is the actor class.
‫Now, the actor class has the ability to be placed in the world.
‫So that's a great start.
‫It also has the ability to have a visual representation.
‫Whether that's a mesh or anything else, it can actually be seen once you place it in the world, provided
‫that you give it a mesh or whatever it is that you want to see.
‫Now derived from actor, we have the -- class and the -- inherits all of those qualities from the
‫actor class, except it has additional qualities such as the ability to be possessed by a controller.
‫Now this whole possession thing is something that will go into more detail about later, but for now,
‫just understand that this means a -- can be controlled by a player.
‫So if you're pressing a mouse button or a keyboard key, this can be set up and configured so that we
‫can move the -- around.
‫So this sounds like something that we would definitely want for our tank.
‫So by handling movement input, the -- is sounding like a pretty good choice now derived from the
‫-- class and thus inheriting all the stuff that the -- has, plus all the stuff that the -- inherited
‫from its parent class.
‫We have the character class which has some character specific stuff.
‫For example, it has something called a character movement component.
‫Now, a -- does not have this.
‫A character movement component gives the character extra abilities such as different movement modes
‫like flying and swimming and crouching and other stuff specific to characters.
‫The character class is good for bipedal characters and it's not going to work very well for non bipedal
‫characters things that are not creatures with two legs.
‫And although it would be pretty awesome to have a tank flying around the level and dropping bombs on
‫everything it sees, we're not going to do quite anything that complicated in this section.
‫We're just going to make a tank that can roll around.
‫So we really don't need a character movement component or any of that special character specific stuff.
‫So for this, I think a -- is perfect for what we're trying to achieve.
‫So I'm going to challenge you to create a new C++ class, create a class based on --, and name this
‫new class based --.
‫Now you can leave all settings as is.
‫In the class creation wizard.
‫You don't need to change the file path or anything like that, so pause the video and create your first
‫C++ class for this project.
‫So back here in the level.
‫So let's go up to tools and create new C++ class.
‫I have not created the C++ class yet.
‫I just closed out of this to go back to that slide.
‫But now that I'm back, I'm ready to create my first C++ class for this project and I'm going to choose
‫-- and you'll see that every time you hover over these.
‫You've probably seen this before.
‫We get a tooltip that pops up and it says, -- is the base class of all actors that can be possessed
‫by players.
‫Or I know that sounds pretty exciting, but we are going to configure this to be movable by input from
‫a player.
‫So this is perfect.
‫It goes on to say that they are the physical representations of players and creatures in a level.
‫So in other words, once we create this tank, it's going to represent us as players in the world.
‫Pretty cool.
‫So select -- and click next and it's showing us the path where it's going to stick this class in our
‫project and you'll see that it's in source slash tune tanks.
‫Now we're going to want to name our new -- because my -- is a horrendous name and it's very vague.
‫We need something a little bit more specific now.
‫We're going to plan on using this as a base class, meaning we're going to derive classes from this
‫class so we can call this base --.
‫Now, I know that's not much better than my --, but hey, it's telling us that this is a base --.
‫This is something we're going to derive child classes from in the future.
‫We'll get to that.
‫But for now, we're going to call this base -- and we're going to click Create Class.
‫All right.
‫So Visual Studio code has opened up for us with our new class.
‫We have based upon H and based upon CP.
‫Now we can close this sidebar by clicking the Explorer icon there, and we can take a look at what V's
‫code has generated for us.
‫So by default we get the class constructor as well as three functions begin, play, tick and set up
‫player input component.
‫Now you should be familiar with Begin, Play and tick the comments here.
‫Explain what they do.
‫Set up player input component is something that the pawn gets and this function allows us to handle
‫input such as from a keyboard key or a mouse click and we'll learn more about how this works in future
‫videos in baseband.
‫CP These functions are defined for us, but they're pretty bare and won't change that in future videos
‫as well.
‫So in this video we created our first C++ class and the next video will discuss components and why we
‫would like to add some to our new class.
‫I'll see you soon.