‫Hello and welcome back.
‫In this video, we're going to talk about the game mode.
‫We're going to use the game mode to set the default -- class for our game.
‫And eventually we'd like to handle Death for the Pawns as well as functionality for starting and ending
‫the game.
‫So let's talk about the game mode class now.
‫Unreal Engine has a class called a game mode.
‫The A is there because of course this derives from the actor class.
‫Now a game mode has a parent class called a game mode base, which is a little bit more basic than a
‫game mode.
‫Now in Unreal Engine, game modes are good for handling the rules of the game.
‫This means they can handle things like the win condition for the game.
‫Now a game mode is a little bit more specialized and has extra functionality that we don't really need
‫for this game project.
‫It has the concept of Match State, which is used in multiplayer matchmaking sessions.
‫So for this reason we're going to use a game mode base and not a game mode.
‫Now the process for creating a game mode class is the same as creating any other C++ class, which is
‫why this will be your challenge for this video.
‫Create a new class based on game mode base.
‫We're choosing game mode base because we don't need that extra functionality in the game mode class.
‫Now call it tune tanks, game mode or something similar.
‫And once you've finished, create a blueprint based on this class.
‫Now we have a pawns folder and an actor's folder.
‫Go ahead and create a new game mode folder and place the new blueprint in the game mode folder.
‫Go ahead and pause the video and create your new game mode class now.
‫Okay.
‫So I'm back here in the editor and I'm ready to create my game mode.
‫So I'm going to right click and select new C++ class from within the tune tanks folder in C++ classes.
‫And I'm going to scroll down and I see here that there's game mode base as an option.
‫Now you'll see the pop up says the game mode base defines the game being played.
‫It governs the game rules, scoring what actors are allowed to exist in this game type and who may enter
‫the game.
‫So we're going to be using the game mode to determine our game rules, which will dictate when we can
‫win or lose the game.
‫I'm going to click next and I'm going to call this game mode, tune tanks, game mode and click Create
‫Class.
‫Now here's my tune tanks game mode.
‫I have a dot H and a dot CP and they look pretty empty and we're going to change that in the videos
‫to come.
‫But for now we have our C++ class and we're ready to create a blueprint based on this.
‫So back here in the editor, I'm going to make my game mode folder here in the blueprints folder.
‫So I'm going to make a new folder called Game Mode.
‫And inside the game mode, I'm going to right click and make a new blueprint class.
‫And here under all classes, I'm going to search for tune tanks and here's Tune Tanks, game mode clicking
‫select.
‫I now have my blueprint and I'm going to call this beep underscore tune tanks game mode.
‫So now I have a game mode.
‫So now that we have a game mode, let's go through the steps of setting this to be our game mode for
‫this game.
‫And we can do that by going into edit and project settings.
‫And under project we see maps and modes and here under default modes we see default game mode and you'll
‫see that it's set to the game mode base class.
‫We can click this dropdown and see that BP tune tanks.
‫Game mode is an option and we can select that now under selected game mode, we can expand this dropdown
‫and you'll see that there are a number of properties on the game mode class that we can set.
‫We can set them here, but what I'd rather do is set them in the game mode blueprint itself so we can
‫close this.
‫There's no option to save.
‫It's already going to save this for us.
‫So we'll close the project settings and open up BP tune tanks, game mode.
‫And here in the details panel under classes, we see a number of default classes designated for the
‫game.
‫Now, the one I'm interested in right now is default -- class.
‫Here we can choose the default pawn that will be possessed when we start the game.
‫So if I click the dropdown, I can see that BP pawn tank is an option and I'm going to select that.
‫So I'm going to compile and save this and close out of it.
‫Now we've set this tank to be possessed using the auto possess player variable.
‫And to remind you, I'm going to search for auto possess player and see that it's set to player zero
‫for this tank.
‫So that allowed us to possess this particular pawn without having our custom game mode set specifying
‫the pawn class.
‫So now that we have a game mode, we're going to remove this pawn from the world.
‫So I'm going to hit delete and delete it.
‫Now I'm going to zoom all the way over to this little thing right here and select it.
‫You'll see that this is called a player start.
‫You can see that here in the world out minor.
‫Now, since we have our default pawn class set in our game mode, when the game starts, our pawn will
‫be spawned right here at the player start.
‫Now if you saw this earlier in the course and maybe decided to remove it, you can always get a new
‫player.
‫Start by looking over here to the left in the place.
‫Actors Panel.
‫You'll see that there are a number of classes we can drag into our world, including player start now.
‫We only want a single player start.
‫If we had multiple player starts then Unreal Engine will be forced to choose one of them at random.
‫But we only have a single player for this game, so we're going to use one player start.
‫So if I go ahead and hit play, we'll see that my pawn is spawn at the location of that player.
‫Start now.
‫I'm moving quite slowly because we're spawning this actor based on the default blueprint and my movement
‫speed is set in the default blueprint to a low value.
‫So what I'd like to do is change my movement speed.
‫So I'm going to go into the Pawns folder and open BP pawn tank and select BP Pawn Tank self.
‫And here under speed I can up this value to say 700 and I'm going to put the turn rate at 120.
‫Now, if I hit play, I can move around quite a bit faster.
‫I'm going to go ahead and save BP -- tank, close out of it.
‫And now we have our game mode set for the game.
‫So in this video, we created the game mode class for our game and we set this as the default game mode
‫both in the project settings and in the world out eyeliner to make sure that our particular level is
‫using the correct game mode.
‫We also set the default pawn class in the game mode blueprint and we used a player start to spawn that
‫default pawn rather than having upon already in the world and using auto possess player.
‫In the next video we're going to add more things to the game mode so that we can start handling gameplay
‫logic related to the rules of the game.
‫I'll see you in the next video.