Hello everyone!
I have a problem with making server-only subsystem work in PIE.
I’ve created subsystem as a child of UWorldSubsystem. I need it to exist only on server, so I’ve overrided ShouldCreateSubsystem function where I check if world’s net mode is not client, like this:
bool UServerOnlySubsystem::ShouldCreateSubsystem(UObject* Outer) const
{
if (!Super::ShouldCreateSubsystem(Outer))
{
return false;
}
const UWorld* World = Cast<UWorld>(Outer);
check(World);
const bool bShouldCreateSubsystem = World->GetNetMode() < NM_Client;
UE_CLOG(bShouldCreateSubsystem, LogTemp, Display, TEXT("Should create subsystem."));
UE_CLOG(!bShouldCreateSubsystem, LogTemp, Display, TEXT("Should not create subsystem."));
return bShouldCreateSubsystem;
}
When I’m trying to launch several clients in PIE with one of them as a listen server, every instance have net mode as NM_Standalone, so every client has this subsystem created, which is not what I want. Outside of PIE it works just fine.
So my question is - is there a way to correctly determine net mode in subsystem when in PIE? Or am I missing something?
Thanks!