Get GameMode before AGameModeBase::RestartPlayer executes (C++)

Hey everyone,

I have a ‘PlayerSpawnManager’ that should self-register itself to my ‘CustomGameMode’. Because this actor is used within CustomGameMode::RestartPlayer override, it has to happen before the first player connects.

I tried to work with overriding PlayerSpawnManager::PostRegisterAllComponents, and indeed, it is called before, but UGameplayStatics::GetGameMode(this); returns NULL at that time.

Any idea?

Context:
I work on a custom spawn system. This ‘PlayerSpawnManager’ gets a reference of all PlayerSpawns in the level and is book-keeping them. Whenever a new player spawns in, the CustomGameMode requests an unused PlayerSpawn from the ‘PlayerSpawnManager’.