Dedicated Server and Gamemode Override

I’m trying to test the networking of my dedicated server but I’m having an issue with the Gamemode as well as level streaming.

I use Rama’s tutorial and have a dedicated server running on my own computer. This opens a map called CityLvlPers that has two streaming levels, a loading screen which would just put up a circular throbber, and the actual city level. Since the loading screen level is just a UI thing, I skip it if the dedicated server opens it. This seems to work fine as I have no errors in the server log and a print to log shows that it is in the right level. CityLvlPers also has a gamemode override, let’s call it ThirdPersonGameMode.

The client opens initially not connected to the dedicated server. The map it opens up is MenuPers, which contains two streaming levels, a splash screen and a main menu. There is no gamemode override here. In the main menu screen, there is a Play button where I hide the menu and use the Execute Console Command blueprint node and call open my IP Address. The server accepts the client and the client is connected. However, the loading screen does not show up first and it just loads the city level automatically. Also, on my PostLogin call, I tried to cast Game Mode to ThirdPersonGameMode but it fails. Oddly, though, it uses the correct Pawn override (ThirdPersonCharacter) since I see the correct mesh of my character.

Any ideas as to why my Game Mode cast is failing as well as the loading screen level not showing up before loading the city on my client?

I will post pictures later to paint a better idea as to what is happening.

As far as the loading screen, this seems to be an issue between PIE and stand-alone.

For your game mode cast, I need to have alittle bit more information, where are you casting for your game mode, are you using the switch has authority with the ‘authorized’ pin?

Oh, so you’re saying if I had a cooked build and instead of using UE4Editor.exe but my own exe, the loading screen level would work.

For my game mode cast, I can’t remember correctly, but I’m pretty sure it is casting in my Gameplay controller, which is also correctly being overriden or else it wouldn’t even be called. So my Pawn and Player Controller are both being overriden but casting the game mode to my overriden game mode fails.

I didn’t think I would need a switch has authority node considering the PostLogin function is and needs to be called on the client. I’m trying to do what the Multiplayer Shootout project does, but via dedicated server instead of player hosted.

Hey, GameMode exists only on server so you can’t cast on it on clinet. What you can do is cast to gamestate which exists on all clients and is replicated to everyone.

Hmm, thanks @syyfilis I’ll see if I’m calling the game mode cast on server or client. I’ll update here later.

Here are my two functions for when a client connects to a server:



The blueprints for this are very similar to the Multiplayer Shootout. The first picture is from my custom game mode that is set to override on my City map. I can see on my server log the TPGameMode OnPostLogin message. The second picture is my custom Player Controller. None is printed onto the screen on my client. I would understand if it was the default GameMode but to have a None game mode is strange.

The difference between my project and Multiplayer Shootout is that instead of calling Join Session, I use the Execute Console Command with open my ip. The server makes the client travel, as I now see the loading screen and then the City level pop up. But why can’t I get a game mode on the OnPostLogin function call while the Multiplayer Shootout works? Would the open command really make a difference?

I read that a dedicated server automatically creates a session but whenever I try to find a session, I never can even when using the batch calls in the tutorial I mentioned in the first post and not using the PIE. This is why I use the open command instead. Do I need to reconfigure my client-server setup?

OK, I figured out the issue, I think.

The reason Multiplayer Shootout does the Get Game Mode cast in that Client Post Login event is for the initial spawning of the listen server, who is also a player (Player 1). Player 2 fails that game mode cast, but still spawns in the second player start because the first player start is already taken so spawning is not an issue. I also believe that if the overridden Event OnPostLogin does not get a chance to Possess the pawn (which happens in the Spawn Player Event), the game will automatically spawn the correct Character blueprint and automatically have the Player Controller possess that spawned Character.

In a dedicated server, that game mode cast will never succeed so it is pointless, but I still need to spawn the players in the correct Player Start with the correct Character actor and have the Possess happen correctly. So, I’m better off just calling the SpawnPlayerEvent directly after getting the Player Controller on the Event OnPostLogin in my own Game Mode, or essentially skip the function call to the Player Controller.

This is theory so I won’t know for sure if this works, but I have a feeling it will.

Doesn’t game mode ALWAYS have authority? as it only exists on server? Should you run “has authority” node there?