Improbable Icon

Unreal Dedicated Server with SpatialOS

Hello, is it possible to mix Unreal dedicated servers and SpatialOS deployments?

My desired setup is:

  • A client-only level where the user performs login
  • A character selection level that connects to a dedicated server to validate user characters/creation/deletion/customization/etc
  • Multiple SpatialOS deployments, one for each game region (a huge world divided into multiple regions, each a separated level/deployment)

Ideally the player would perform login, when authenticated it would be transferred to one dedicated unreal server with available capacity (that would manage the player character selection/creation), with a character selected, the player would be transferred into the level where the chosen character was located last time the user logged out.

We are already using our own authentication flow and I can directly move from the login level into a test game world (cloud deployment), but if I add the dedicated server into this mix I get some errors when running it with SpatialOS network enabled (I believe it’s trying to run as a worker) and without it I cannot perform a ClientTravel() to a deployment.

We will eventually build or own server to handle the character flow, but for now it would be easier, specially since the game is changing frequently.

I actually did this yesterday so I can tell you exactly how it works =D

Basically you have to set a new UNetDriver when you connect to a non-spatial server. The UE4 default is OnlineSubsystemUtils.IpNetDriver. When bSpatialNetworking is enabled in Project Settings, Spatial uses its own NetDriver class (SpatialNetDriver) and server connection logic.

The quickest way I found to override Spatial networking was to copy the logic in USpatialGameInstance::HasSpatialNetDriver(), and replace the SpatialNetDriver path with your desired driver. Take a look at that to see how it sets up and initializes a UNetDriver for SpatialOS.

I believe (but am not certain) you also need to set bSpatialNetworking=0, otherwise the connection flow may still try to send SpatialOS initialization packets instead of Unreal defaults. I did that by running GeneralProjectSettings->SetUsesSpatialNetworking(1) alongside the logic above.

It’s very helpful to look at the client’s logs when you attempt to connect; if you see IpNetDriver in use but timing out for no reason, it means SpatialNetworking is still enabled in the network stack.

1 Like