Update Player States from GameMode at BeginPlay

As I know, UE creates classes in such order Player Controller -> HUD -> Game Mode -> Game State -> Player State -> Level
And I need in the BeginPlay of GameMode update values in all Player States.
Now I use Delay Blueprint node for 2 seconds and then call function in GameMode that updates **Player States. **How can I get rid of that delay?
Is there a way to track down when Player State gets created?

My experience with load order shows that it varies depending on varying factors. Is the game SP or MP? Are you launching in PIE / Stand Alone / Packaged game?

In general though Game Instance is first. Then you’ll have Game Session which if memory serves is what creates the controller. From there its UWorld (level) which loads the config stipulating specific classes: mode, character, hud, controller, game state, player state etc. Game mode is then loaded etc.

You can open each of your classes (GM, GS, PC, Character etc) and use On Load or better Begin Play to print its class type to Log.
e.g. GM : begin play -> Print: Game Mode

Once you have the order you can have the last to load major class call an event in say the GM to initialize your own sequence of begin/start logic.
e.g. GM -> Create Players, get game save data, update character classes / player states etc

edit …

For the most part load/spawn orders are non-deterministic. They can change on compile etc.

I see three posibilities to improve this:

  1. Do the initialization in PlayerState. Create Functions in the GameMode so that the PlayerState can query whatever information it needs to be initialized, making the PlayerState the active part and the GameMode the passive one (kind of a role reversal to your approach).
  2. Similar to 1 on PlayerState BeginPlay call a Custom Event on the GameMode, but this time simply to inform it that the PlayerState is now ready. Then you can do the initialization with the GameMode being the active component in this Custom Event.
  3. Use atimer function to periodically poll the PlayerState until its there, then clear the timer. Not the most efficient solution but it works.

All of these are reliable in contrast to guessing the time it takes for the PlayerState to be initialized, as this can be different in every environment/runtime.
Hope that helps!