# Persistence vs Authority

**URL:** <https://community.coherence.io/t/persistence-vs-authority/547>\
**Category:** Help\
**Created:** [June 30, 2024, 4:16pm UTC](https://community.coherence.io/t/persistence-vs-authority/547 "2024-06-30T16:16:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![periwink](https://avatars.discourse-cdn.com/v4/letter/p/59ef9b/32.png) [@periwink](https://community.coherence.io/u/periwink)\
**Post date:** [June 30, 2024, 4:16pm UTC](https://community.coherence.io/t/persistence-vs-authority/547/1 "2024-06-30T16:16:25Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![cary](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/cary/32/37_2.png) [@cary](https://community.coherence.io/u/cary)\
**Post date:** [June 30, 2024, 4:41pm UTC](https://community.coherence.io/t/persistence-vs-authority/547/2 "2024-06-30T16:41:11Z")

</div>

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](https://docs.coherence.io/coherence-sdk-for-unity/client-messages)

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.

---

<div class="post-metadata">

**Author:** ![periwink](https://avatars.discourse-cdn.com/v4/letter/p/59ef9b/32.png) [@periwink](https://community.coherence.io/u/periwink)\
**Post date:** [June 30, 2024, 9:45pm UTC](https://community.coherence.io/t/persistence-vs-authority/547/3 "2024-06-30T21:45:40Z")

</div>

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” ?

---

<div class="post-metadata">

**Author:** ![cary](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/cary/32/37_2.png) [@cary](https://community.coherence.io/u/cary)\
**Post date:** [June 30, 2024, 11:31pm UTC](https://community.coherence.io/t/persistence-vs-authority/547/4 "2024-06-30T23:31:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ciro](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/ciro/32/82_2.png) [@ciro](https://community.coherence.io/u/ciro)\
**Post date:** [July 1, 2024, 5:57am UTC](https://community.coherence.io/t/persistence-vs-authority/547/5 "2024-07-01T05:57:34Z")

</div>

> [@periwink](#):
>
> 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

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

> **[Server-authoritative setup | Unity Multiplayer SDK Documentation | coherence](https://docs.coherence.io/coherence-sdk-for-unity/authority-overview/input-queues)**

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.

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex017/uploads/coherence/original/1X/b3aa79eb9519fac7aad7eba18f15a1e8ce60f6e2.png) [@system](https://community.coherence.io/u/system)\
**Post date:** [September 29, 2024, 5:58am UTC](https://community.coherence.io/t/persistence-vs-authority/547/6 "2024-09-29T05:58:20Z")

</div>

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