Download

Multiplayer respawning, Can I teleport instead of destroying and spawning again?

So in my multiplayer game which uses a listen server (host/client), I attempted to implement a death/respawn system and was failing miserably.

https://wiki.unrealengine.com/Bluepr…player_Respawn
I followed this guide (except did it in C++ and got rid of that if not authority check) but it wasn’t working fully. When there are 2 players, it works, but when there is a 3rd player, it spawns an extra character (2 instead of 1).

In the end I found a very simple solution and all the logic is in my pawn class. I made a Death function which is a NetMulticast and I call that in TakeDamage. In the Death function, I play death animation, disable input and call respawn after 10 seconds. Respawn just resets health back to full, enables input and teleports the player to the player start.

All the information is still there and I don’t see any downsides. Is there any problems with my new method? Its functioning just as good as deleting and spawning the player with no bugs so far

If it’s functioning as intended, I don’t see where there’d be a problem.

However it’s interesting you have an unintended extra character spawning. Possibly this means a client is replicating an action that it shouldn’t be?

I see. Every demo (like Shooter Game or Multiplayer Shootout) I saw, they usually destroy the player and spawn them. I’m guessing its for if you want to change to a different character or something but in my game, you’re supposed to be stuck with the same character until the match is over. Then you go to the lobby. I guess I’ll keep it my way then.

You should destroy the dead pawn usually, and actors should only ever be spawned (or respawned) on the Server. You don’t want the clients to be setting health variables or anything like that.

Just call ‘RestartPlayer’ on the Server from the GameMode, and that will respawn the player properly with a new pawn. If you need to transfer properties from the old Pawn, my suggestion would be to save them in the PlayerState and restore them (on the server!) when the new pawn is spawned.

I didn’t know such a convenient function like RestartPlayer existed. Makes things so much easier. I’ll use that then. Thx for the help!