Dedicated Server - How to properly initialize GameState?

Hey everyone, I am sure this is a newbie question but how is someone meant to initialize their game state BEFORE any clients connect on the server side?

I tried doing this in the GameMode until I learned that this is not replicated on the clients so I want to do it in the GameState.

I have a custom GameModeBase and GameState setup for my project but in the GameMode::InitGame hook, the GameState is a nullptr so I cannot really configure it.

I have read multiple guides, videos, UE source code, graphs, but nothing seems to point in the right direction when initializing your server before clients log in.

Never mind, managed to solve this on my own. The AGameModeBase::StartPlay hook was what I was looking for. I introduced my logic before invoking the Super::StartPlay hook to ensure any play hooks are invoked after I have properly set up my GameState.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.