> For the complete documentation index, see [llms.txt](https://docs.coherence.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coherence.io/2.3/manual/simulation-server/advanced-simulator-authority/simulator-query-transfer.md).

# Simulator query transfer

In an advanced Simulator setup, where entity creation is restricted to the Simulator, it is not possible for a Client to create their own queries. In [an unrestricted setup](/2.3/manual/networking-state-changes/authority/server-authoritative-setup.md#interaction-with-livequeries) you can create a live query Prefab that has a [CoherenceSync ](/2.3/manual/components/coherence-sync.md)behaviour with the *Simulate On* property set to *Server Side with Client Input*. However, in order to provide a Client with a live query in an entity-restricted setup, the Simulator has to create the live query on behalf of the Clients and transfer the input authority back.

<pre class="language-csharp"><code class="lang-csharp"><strong>using UnityEngine;
</strong>using System.Collections.Generic;
using Coherence.Connection;
using Coherence.Toolkit;

public class SimulatorConnectionHandler : MonoBehaviour
{
    public CoherenceBridge bridge;
    public CoherenceSync liveQueryPrefab;

    private Dictionary&#x3C;ClientID, CoherenceSync> clientQueries = new();

    public void Start()
    {
        bridge.ClientConnections.OnCreated += HandleClientCreated;
        bridge.ClientConnections.OnDestroyed += HandleClientDestroyed;
    }

    public void OnDestroy()
    {
        bridge.ClientConnections.OnCreated -= HandleClientCreated;
        bridge.ClientConnections.OnDestroyed -= HandleClientDestroyed;
    }

    private void HandleClientCreated(CoherenceClientConnection client)
    {
        if (client.IsMyConnection)
        {
            // This example is only creating live queries for other clients.
            return;
        }

        // Create a live query for the client and transfer the input authority so
        // they get the benefit of the query, but are not allowed to modify it 
        // directly.
        var clientQuery = Instantiate(liveQueryPrefab);
        clientQuery.TransferAuthority(client.ClientId, Coherence.AuthorityType.Input);

        clientQueries.Add(client.ClientId, clientQuery);
    }

    private void HandleClientDestroyed(CoherenceClientConnection client)
    {
        if (client.IsMyConnection)
        {
            return;
        }

        // Destroy the query that belonged to the disconnected client.
        var clientQuery = clientQueries[client.ClientId];
        Destroy(clientQuery.gameObject);

        clientQueries.Remove(client.ClientId);
    }
}
</code></pre>

Constructing a Prefab that has Simulator authority but benefits a Client with the area of interest is simple. It requires that the *Authority Transfer* mode is *Request* and that there is a [Coherence Live Query](/2.3/manual/components/coherence-live-query.md) component. It is also possible to add any kind of query to these Prefabs or multiple types and the Client will benefit from them all.

<figure><img src="/files/2GoNasjY54H34gXaMBdW" alt=""><figcaption><p>The <strong>Simulate in</strong> field is set to <em>Client Side</em>.</p></figcaption></figure>

{% hint style="warning" %}
Note that the **Simulate In** field is set to *Client Side*. This is appropriate for this setup even though the state authority of this entity is a Simulator, since from the point of view of the Replication Server all Simulators are Clients as well.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coherence.io/2.3/manual/simulation-server/advanced-simulator-authority/simulator-query-transfer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
