Introduction

I am starting a new game which will be a combination of real time strategy and battle royale genres. I will build the game purely with C++. I will try not to use any blueprint classes even for the HUD of the game (I may make an exception for animations since currently I don't know if it is possible with C++ or not, but we'll see 🙂 ).

This project will include game mechanics, shader, user interface, and network implementations with pure C++.

I think this project can be a very good source for C++ game development with Unreal Engine where there is not enough sources for C++ developers but blueprints.

Of course it would be much easier with blueprints, but I am not here to study or understand how games are done with blueprints(Leaving aside the engineering part of it surely.).

We will start with an empty C++ project and first thing we are going to do will be to create the main classes of the game (GameMode, GameState, PlayerState, PlayerController, SpectatorPawn, and HUD classes).

A Little Bit Of Starting

Before starting the project let me explain the main classes we will be creating:

GameMode Class:

There are two main classes which handle information about the game being played: Game Mode and Game State.

  • The number of players and spectators present, as well as the maximum number of players and spectators allowed.
  • How players enter the game, which can include rules for selecting spawn locations and other spawn/respawn behavior.
  • Whether or not the game can be paused, and how pausing the game is handled.
  • Transitions between levels, including whether or not the game should start in cinematic mode.

Says the documentation of Unreal Engine(Source: https://docs.unrealengine.com/en-us/Gameplay/Framework/GameMode).

From this explanation, we can understand that the GameMode class is the heart of the game. It controls everything about it.

We will be setting our main player, player controller, etc. in our GameMode class construction and it will create every one of them when the game is started. Understanding the GameMode class is the first essential thing in order to develop C++ games with Unreal Engine.

GameState:

Again let the pros talk and quote how they describe the GameState:

The Game State is responsible for enabling the clients to monitor the state of the game. Conceptually, the Game State should manage information that is meant to be known to all connected clients and is specific to the Game Mode but is not specific to any individual player. It can keep track of game-wide properties such as the list of connected players, team score in Capture The Flag, missions that been completed in an open world game, and so on.

Since we are going to develop a multiplayer game we are going to need the GameState class in order to store our players' list, team scores and so on.

The beautiful thing about Unreal Engine networking is that it handles most of the things for us. For now, let me tell that the GameMode is only being stored in the server, but the GameState class is stored in the server and replicated to all the clients in order to make them aware of other players.

Game Mode settings of the game.

I will be explaining the other classes in the following articles. Until then take care!