Keeping character in-world after player leaves

Hello All!

I’m attempting to create an online game which keeps the player character in the world after the player leaves.
Unfortunately I can’t seem to figure out how to do this, or even if this will work correctly while running in-editor, I know something needs overriding but I’m not entirely sure where.

For testing I use a .bat file to run the dedicated server and then run 2 clients from the editor itself, one to connect and disconnect.

I was having a look at the AH post but it didn’t help: How to avoid engine destroy the character when player leave or get disconnect - Multiplayer & Networking - Unreal Engine Forums

Hopefully someone here can shed some light on this, thanks!

At first, I thought it was handled by Logout in Gamemode but I took a closer look at it and it seems like its handled by HandleSeamlessTravelPlayer(). I suggest you look into this. Once I override this function, it does not destroy the pawn upon leaving the level.

More specifically, this function called Destroy on PlayerController. Inside that function, it handles what it should do with the pawn when leaving the game. Upon looking further into it. you could just override “PawnLeavingGame” function in player controller.

Overriding PawnLeavingGame in the Player Controller did the job.

Alternatively to Koraemon answer, you can also try UnPossess your pawn on Player Controller End Play Event on server side. (not tested)

I tried this and it didn’t work for me