Hi there,
I would like to know if this is the intended behavior that I am getting, or is it just me doing something wrong. What I want to do is to execute a server side logic in scene actors. Both actors check if it is the dedicated server running with:
GetWorld()->GetNetMode() == NM_DedicatedServer
I have the following setup:
- Editor running with the Run Dedicated Server checkbox
- 2 Actors that have server specific logic
Actor 1 is placed in the scene and does its server side logic in PreInitializeComponents().
Actor 2 is spawned via Blueprints and Initialized via Blueprint function which has server logic on Begin play
When I play the level in the editor, I am getting the following results:
- Actor1 Server Check - not dedicated
- Actor2 Server Check - dedicated
- Actor1 Server Check - not dedicated
- Actor2 Server Check - not dedicated
I looked into the implmentation of the GetNetMode() and it turned out that if no NetDriver is set, the function defaults to
return NM_Standalone;
After this, I have set a breakpoint everywhere where the NetDriver is set and the result was this:
- Actor1 Server Check - not dedicated
- UWorld::Listen - Set NetDriver
- Actor2 Server Check - dedicated
- Actor1 Server Check - not dedicated
- Actor2 Server Check - not dedicated
Now, this seems like a race condition and I am not really sure what is the best way to deal with it.