Client not receiving Rpc calls after its player is despawned/destroyed

Trying out distributed authority. Rpc calls work well, until the client’s player object is despawned and destroyed. Then the client can no longer receive Rpc calls. However he can still send Rpc calls and the server recieves them. If the server spawns a new player object for the client, he can once again receive Rpc calls.

This is quite weird, and I am wondering if this is expected behaviour? I have other network objects owned by the client and the server and client are connected still.

  1. Since the client owns its player object, the client itself is calling despawn and destroy on it.
  2. Then he sends to the server that he is dead.
  3. The server then either spawns a new player object if the client has more lives, or the server sends “game over” - rpc.

The client will not receive the game over - message, unless the server is the one that dies.

The workaround for now is to have the client NOT destroy its player game object until another client player object have been spawned by the server. Then everything works fine.

It matters which script sends/receives these RPC messages. If the script is on the player object that has now been destroyed, then obviously that script shouldn’t receive any more RPC messages.

Also, just in general, I often see this “actor dies = destroy object” pattern implemented by devs which has all sort of issues even in singleplayer and specifically for the player.

You never want the player object to get destroyed, or even replaced by a “dead player” object. Instead, your player object always exists throughout the lifetime of the session (at a minimum). It’s the child objects, like the mesh with the animator and such, that you may want to destroy or hide. The child objects also aren’t networked because they needn’t be.

Think of your player object as merely a container of scripts synchronizing its transform. Every child of that object is non-networked but may have a network interface script on the main player object, eg for shooting, looting, and such. This gives you far more flexibility and it’s easier to implement any kind of “mode”, be it dead or driving or being placed on a pedestal post-game.