Where do I have to put actions when the game state changes

I’ve just started to learn Unreal Engine implementing a clone version of Atari’s Pong game.

I’m thinking about where to put the code to change the state of the game. I have an enum in the GameState class to manage when the game hasn’t started, or when we are playing the game. In case when someone scores I decided that I have to stop the ball and move it to its initial position.

My problem comes here because I don’t know where to put the code to do that: on GameMode class or on GameState class.

Where do I have to put that code?

GameMode should drive your game’s logic:
PlayerA scored! Let’s notify the game state that PlayerA scored, then respawn everyone and reset the ball.

GameState should give you information about the state of the game:
PlayerScored event is called. Let’s update the score counter for the players. We can read the scoring player’s name, and display it on the screen as well.

With that said, separating GameMode and GameState correctly is only needed if you are working on a multiplayer project. In that case, the server will have both a GameMode and GameState, while clients only have a GameState. Also feel free to use the GameModeBase and GameStateBase classes instead. They have less features, so that you can design a more suitable solution for your project.

Thanks for your answer. Yes, I’m using GameStateBase and GameModeBase.

Although, it is not a multiplayer game (yet), I’m going to put all the logic on GameModeBase class, and the score into GameStateBase.

And please, if you have another suggestion to do it, please share it with us (I’m learning and I want to know any other points of view about how to do it).