Are you new to Unreal Engine and feeling a bit lost about where to begin? Maybe you’re not even sure what a Game Mode is?
Well, you’re in the right spot! This is a beginner’s guide about the Game Mode Blueprint Class in Unreal Engine 5.
Don’t worry, we won’t dive into complicated C++ or advanced stuff. Instead, we’ll focus on learning how to use it and why having one is essential in all your Unreal Engine projects.
This blog post will be expanded in the future, but for now, let’s keep it easy to understand.
What is a Game Mode?
Okay, let’s make this easy! A Game Mode is like the master or brain of your game.
It’s where you decide all the rules for your game or project in Unreal Engine. You get to choose things like which player is playing, how many players and spectators are allowed, and even decide on things like the controller, HUD, player, and game state.
The selected Game Mode automatically starts when you begin playing, allowing its information to be accessed from anywhere in Blueprints. Check out our lesson on Casting in Blueprints to find out more about it.
In the Game Mode, you can set up the following Blueprints:
- Default Pawn Class
- HUD Class
- Player Controller Class
- Game State Class
- Player State Class
- Spectator Class
If you’re a beginner, all you need to focus on right now is the Default Pawn Class. You’ll change it about 99% of the time.
Here, you’ll set up your character, whether it’s in the first person or third person. It doesn’t matter.
1. Create a Game Mode in Unreal Engine
You have three methods to create a Game Mode. Use the one you like the most, they all open the same window.
To create a Game Mode, simply right-click on the Content Drawer or use the ‘+ Add‘ button, then select ‘Blueprint Class.‘
As a third method, simply click on the Blueprint icon and choose ‘New Empty Blueprint Class…‘
In the new pop-up window, simply choose ‘Game Mode Base‘. Give it a name, and save it.
2. Set the Game Mode in Unreal Engine
Now, you should have a Game Mode Blueprint Class file in your Content Drawer. In my case, I named mine ‘GM_GameDevEXP‘, but feel free to choose any name you prefer. Just remember it.
However, you can have as many Game Modes as you want in your project. You can create a second Game Mode right now if you want. Therefore, we need to tell Unreal Engine which Game Mode we want to use for this level.
Game Modes can be specified for levels and for the whole Unreal Engine project. But a Game Mode can’t be changed while playing a level or map.
Setting Up the Game Mode in the Project Settings
So let’s specify which Game Mode we want for our project.
To do this, go to the top main menu and select ‘Edit’ -> ‘Project Settings…‘
Type ‘Game Mode‘ in the search bar.
Here, you can pick a different Default GameMode. Change it to the Game Mode you created in the last step.
Setting Up the Game Mode in the World Settings
If we have specified the Game Mode in the Project Settings, when do we need to change it in the World Settings?
You need to change it when you have a new level with different mechanics, for example, different movement or another character. Just a level with new rules.
For instance, you can create a Game Mode for a 2D Platformer like Super Mario Bros. Set up this game mode for your whole project. However, for the water level, create a new Game Mode that will override the default one, but only for this specific water level.
To do it, open the ‘World Settings’ window and in ‘GameMode Override’ select the one that you created.
3. Change the Default Pawn Class
Now it’s time to test if the Game Mode is working. As I explained before, the Default Pawn Class is the class that you are going to replace the most. Let’s use it to test if the Game Mode is active and working properly.
To do this, just create a Character or Pawn Blueprint Class. Follow the same steps as in Step 1, but this time select ‘Pawn‘ or ‘Character.’ These are the most commonly used classes to create a character, but you can choose another class if you are a more advanced developer.
After creating it, open the Blueprint. If you’ve never created a character before, check out our lesson on Blueprint Actors.
To keep it simple, just add two components to the Blueprint: a cube and a camera.
Compile and save, then add a ‘Player Start‘ in your level wherever you want to start the game.
Now, go back to step 2 and change the ‘Default Pawn Class‘ in the Project Settings or World Settings. Select the Blueprint you just created for the ‘Player’, which is currently a cube for testing purposes, but you can change it later.
If you’ve done everything correctly, when you press the play button, you should see the cube and the camera, as the player is being selected at the start of the game.
I will be extending this article with more information about the Game Mode, as well as other Blueprint Classes and more advanced topics such as multiplayer, Game States and Game Instances. For now, you can continue reading our Unreal Engine Roadmap to learn more about Unreal Engine. Or read the Unreal Engine documentation.
I hope it helped! Keep creating!