Persistence vs Authority

The docs state that persistence is tied to the client/simulator that has authority over it.
But what if for I have a server-authoritative model; e.g. a client connects, spawns a player entity over which the server has authority.
Then when that client disconnects, I want the entity to disappear.

Is this possible?
I was under the impression that persistence only kicks in if the client that has authority over an entity disconnects.
How to model entities that are ‘controlled’ by a client, but are still simulated by the server? (server-authoritative)

Hey yeah, this is a common pattern for simulator authoritative games. You’ll want to use the client connection system on the simulator to detect when the client disconnects so you can destroy their entity. Client Connections | Unity Multiplayer SDK Documentation | coherence

One challenge is relating the client ID of the client that created the entity to the entity so it is often easier for the simulator to create the entity on client connection and transfer input authority so you immediately have the relationship info. Otherwise you will probably have to include the client ID as a sync field on the entity so the simulator knows which client created it. There are a number of solution for this.

Hi, thanks;
So basically the Lifetime configuration of the network object doesn’t help in this case, and I have to handle this myself in the simulator code by listening for “client disconnected events” ?

Yeah leave lifetime as session based. And listen on the simulator for creating and destroying client connections.

By the way, this behaviour (Server-authoritative with client input) is described here:

And you need a Simulator for it (that’s what we call servers).

Then you can do what Cary suggests: the Simulator watches over the player joining and leaving by keeping an eye on their ClientConnection.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.