2
\$\begingroup\$

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?

\$\endgroup\$
1
  • \$\begingroup\$ It's related to networking. GameMode only exists in the server, GameState exists everywhere. \$\endgroup\$ Commented May 19, 2021 at 12:13

1 Answer 1

1
\$\begingroup\$

The GameMode is for storing the rules of the game.

GameState is for keeping track of the game statistics like score etc. In a pong type game, it would also keep track of whose turn it is to serve next.

GameState is the better place for what you're trying to do.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks for your answer, but why? I think what happens after some makes a score is a game rule. \$\endgroup\$ Commented May 19, 2021 at 10:07
  • \$\begingroup\$ Sorry but I still don't understand your answer. I have to start the game on GameMode, because it has the method StartPlay, which is not present on GameState, and then continue the logic of the game on GameState. \$\endgroup\$ Commented May 20, 2021 at 14:31

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.