Dev log 05/03/2021
Migrate game mode rules and game states
The coin collection rules and score totals were originally kept in the game mode but this isn’t the standard process according to the official documentation when dealing with multiplayer games. See below:
Although the game mode can handle score events, the game state is better used to handle more gameplay specific information based on the documentation e.g. team scores. This information can then be accessed from the game state from clients connected to the network.
To follow this methodology, a new game state class was created. Then new methods were added for Get and Set for both the red and blue team scores. The get/set methods are public and can be called from blueprints and other C++ classes including the game mode. The old methods existing in the game mode were removed as these were no longer needed.
Two new variables called RedTeamScore and BlueTeamScore was also added to the game state to represent both teams individual total points. These score variables are replicated so that all clients are made aware of teams scoring points.
Game state Team score methods
The game state is public by default and accessible from the player UI. The Player UI has two bindings in a widget container for blue team and red team score that updates when the value changes in the game state.
Player UI - score text update
Two players were used to initial test the game state and the score updated correctly for both teams.
Further testing was carried out with 4 players, one acting as the host and three as clients connected to the session. When a coin was collected, the correct score was replicated over the network. This confirms that the game state is receiving the score variables updates and that this information is accessible from the network as intended.
Coin destroy time
From the previous development session to do list, the coin destroy time has been reduced by setting lifespan to 0.2f or ⅕ second. This allows time for the object to be removed and to update all clients over the network.
Implement game loop state machine
The Game loop state machine has been implemented within the game state class. This is rudimentary with no calls from game mode yet. There are no function calls within the state machine to trigger events but these will be added later.
Match state machine
To do list
Move the Player current score into the player state not the character - this is to allow for when a player possesses another pawn and reduces the need to pass that variable around as stored in a single container. Also sticks to multiplayer concepts with a player having their own “state”.
Connect the match states to the game mode so that events are triggered when game play conditions are met.
Comments