When to use GameMode, GameState, PlayerState, etc

Hi, new to Unreal Engine (ex Unity user) and doing a small experimental Space Invaders type project to get to understand the engine. From the perspective of spawning , shooting , etc all good so far. It works!

What I can’t get my head around after reading and re-reading the documentation is the subtleties of the various GameMode, GameState, PlayerState, Level, etc.

I’ve got conceptual problems and some real problems:

  • Real Issue – If I want to get keep
    state information that goes across
    levels, where should that be stored?
    GameMode , GameState all get
    re-created at the beginning of a
    level.
  • Conceptual issue – I got a score.
    I’ve put the variable in the score in
    GameState (originally had it in
    GameMode) . If I had a multiplayer
    mode should it be in PlayerState?
  • Conceptual issue – To access some of
    the functions in GameMode /
    GameState, in BP I need to GetGame
    state and then cast it my Game State
    state class. This seems really
    clumsy , I am going about this wrong? See screenshot.
  • Conceptual issue – Currently my
    GameMode does the spawning of the
    actors and in charge of some of the
    movement logic. It works but is that
    the right place to be doing it? Whats the implication multiplayer.
  • Conceptual issue – I cant fathom what
    the flow should be for a standard
    game where you have a menu where you
    press start, something then kicks off
    the game, at the end returns to a
    menu / hiscore. I’m guessing I can have levels for start screen that then kicks off the game, but then I’m lost on what to do for global state.

I will extend this to then be multiplayer (simultaneous players at the same time) and I figure if I can do that I would have understood the key aspects of the UE engine (which I very much like so far apart from the lack of static mesh (vertex) animation).

“•Real Issue – If I want to get keep state information that goes across levels, where should that be stored? GameMode , GameState all get re-created at the beginning of a level.”

I found what I needed. Looks like I need to use a GameInstance .

For your conceptual issues you might find some help in this thread: https://answers.unrealengine.com/questions/122429/gamemode-vs-gamestate.html