Networking - Level Streaming - Character falls through floor when engine spawning

Hello!

I am learning Level Streaming in my Multiplayer game.

The problem: Sometimes when I start the game in the editor, the pawn of the host (listen/server) falls through the map. It happens pretty often.

I copied the BP_ThirdPersonCharacter and named it “BP_LobbyCharacter” so I didn’t change any collision settings.

I also made sure that the player start actors are slightly above the floor.

that’s potentially a race condition with the streaming and the pawn spawning.

possible solutions:

  • delay spawning the pawn until the floor has been loaded. you’d need to detect the stream loading finished. and disable automatically spawning pawns.
  • add a blocking volume under the spawn points or have a floor in the base level, not a level streaming.

Thanks for your quick reply! Very good hints.

I noticed something. When I unplug the true branch where I check whether the level is loaded and visible in BP_PC Begin Play and do not call the server rpc, the pawn is spawned nonetheless ! So I was wondering how this can happen and I came across the 4 overridable functions from GM:

  • HandleStartingNewPlayer
  • Choose Player Start
  • Player Can Restart
  • Spawn Default at Transform

If HandleStartingNewPlayer Event doesn’t call a parent function, it will block the spawning chain, right?

So in Begin Play of BP_PC (My Player Controller), I can wait till the level is loaded+visible, then call a Server_RPC with the client as input and manually call “ChoosePlayerStart” and afterwards “SpawnDefaultAtTransform”?

I’d love to override “Player Can Restart” where I pass a boolean as an input. But it appears as if I can’t pass an input parameter to this function when I want to override it. So I just override it and set it to false always - just in case if HandleStartingNewPlayer leaving empty doesn’t work / isn’t enough to block the spawning chain.

This would be my solution. I’ll implement this after I catched some sleep :slight_smile:

Thanks!

Cheers,
Dreamerich

i’m glad it helps.

dunno why your post looks like chatgpt.

i have no idea what you’re talking about. it would be good that you share your code.

don’t call an rpc in begin play, ever. it’s superfluous and might fail.

the game mode and the player controller have settings to automatically spawn a pawn.

I am totally confused. I tried what I wrote above. Did not work.

My 2nd approach:

  • I implemented a boolean in BP_PC “bHasLoadedLevel”
  • I overrode “Player Can Restart” where I use the input PlayerController object from the function to get the bHasLoadedLevel and directly pass it to the return node to prevent spawning when the level isn’t loaded yet.
  • In BP_PC “Begin Play”


The problem:

→ While both clients (Host/Client 1) spawn their characters, host’s pawn is not controllable

Possible soft-lock

  • Someone told me that client loads the stream level faster than server.
  • Therefore, the server can’t catch up and soft-locks the client and prevents him from spawning.

My 3rd approach

  • My idea was to use switch has authority on BP_PC Begin Play where I use the authority pin to load the Stream Level. When I use this way, I can save a boolean afterwards “bServerLoadedLevel”
  • After this, I use a switch has authority for the remote pin and repeat this procedure where I save a boolean “bClientLoadedLevel”.
  • And in “Player Can Restart” I’d use these 2 booleans from the player controller object to do a AND-Boolean check and pass it to the return node.
  • When the bClientLoadedLevel is set, I’d use a Server RPC to do “Restart Player”.
    → I know what you wrote there with " Dont use RPCs in Begin Play". But I have no idea how else I can do it.

the problem

→ Both clients are in spectating view. No pawn spawned

What I noticed in 2nd/3rd approach

  • In Debug Mode when I plug in a debug modifier on Begin Play, the debug flow stops at Load Stream by Level.
  • So I can never see the rest what happens next
  • But when I unplug the server RPC “Notify Level Loaded”, the pawns are never spawned in 2nd approach. So they must be executed although I can’t see it in debug mode.