My TArray of one structure works when declared inside a function, but not when declared on header file

Ok. You are calling beginplay on the derived class AActor that AGameModeBase inherits from. I’m not sure of the order in which it is called in that case. (maybe it’s random)

I would strongly suggest to use the InitGame function in place of beginplay

Information from within the gamemodebase class:

/**
 * Initialize the game.
 * The GameMode's InitGame() event is called before any other functions (including PreInitializeComponents() )
 * and is used by the GameMode to initialize parameters and spawn its helper classes.
 * @warning: this is called before actors' PreInitializeComponents.
 */

You will be sure it is called before any of your characters

1 Like