# Help with Coherence sync prefab ( player ) not syncing variables from Simulator to non-authority

**URL:** <https://community.coherence.io/t/help-with-coherence-sync-prefab-player-not-syncing-variables-from-simulator-to-non-authority/338>\
**Category:** Help\
**Created:** [July 26, 2023, 5:30am UTC](https://community.coherence.io/t/help-with-coherence-sync-prefab-player-not-syncing-variables-from-simulator-to-non-authority/338 "2023-07-26T05:30:01Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marvin\_Sorensen](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/marvin_sorensen/32/300_2.png) [@Marvin\_Sorensen](https://community.coherence.io/u/Marvin_Sorensen)\
**Post date:** [July 26, 2023, 5:30am UTC](https://community.coherence.io/t/help-with-coherence-sync-prefab-player-not-syncing-variables-from-simulator-to-non-authority/338/1 "2023-07-26T05:30:01Z")

</div>

I feel like I must be missing something simple because this is working for a client connecting to the Simulator.

The client connecting has a child object that is getting a rotation value based on coherence input.

This client has Input Authority, and State Authority on the Simulator.

On the Simulator:  
 ![image](https://europe1.discourse-cdn.com/flex017/uploads/coherence/original/1X/748198f4bef18ea1a0bd49340daee686f4e5aaa5.png)

And setup like:

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/coherence/original/1X/7c2f8768fb890900feda744d1cbf3a204e122479.jpeg)  
Which shows the connected client child object, it’s setup for sync ( set to sync rotation ), and Rotation values in the inspector.

I connected a second client w/ the Unity Editor to the same Simulator to be able to view/inspect the other connected clients.  
The same connected client w/ no authority ( what other clients would see ):  
 ![image](https://europe1.discourse-cdn.com/flex017/uploads/coherence/original/1X/89781c1f8ccb7e1513c8559a4024cd22b8a7cf2f.png)

And viewing the setup in the inspector:

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/coherence/original/1X/7b0058db846be64567254ede8ddba96a6991563c.jpeg)  
Viewing the same child object, showing that it has rotation sync, but has no Rotation values.

Shouldn’t the values from the Simulator be synced to non-authority network objects as well? I found another answer post, and the suggestion was to turn off interpolation. I tried both default & none, but it was the same.

---

<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 26, 2023, 11:35am UTC](https://community.coherence.io/t/help-with-coherence-sync-prefab-player-not-syncing-variables-from-simulator-to-non-authority/338/2 "2023-07-26T11:35:41Z")

</div>

Hey Marvin.

Before I go into the post (haven’t even read it fully), I want to clarify one thing. You don’t connect Clients to Simulators. You could imagine Simulator and Clients on the same conceptual level: they are all Unity builds connecting to the Replication Server (RS).  
Just wanted to mention it in case it was unclear.

From the images I can’t tell much. But my hunch tells me that probably, on both instances of the editor you have the input script running, which is forcing that object to be rotated in a certain way. So even if in the second screenshot you should be using the rotation that is coming from the network (because the object is remote), you might be forcing it to a certain value every frame, so you never see it update.

To resolve this, make sure that the input for remote objects is not active. That your script(s) are not modifying values that they shouldn’t.

We have a quick way to do this using the Components part of the Configuration panel (the one shown in the images). This behaviour is described on this page, specifically at this section: [Prefab Setup: CoherenceSync - Unity Multiplayer SDK Documentation | coherence](https://docs.coherence.io/get-started/prefab-setup#5.-disable-input-on-replicated-object)  
Give it a read 🙂

I would also suggest reading through at least the first 3 sections of this tutorial: [First Steps tutorial - Unity Multiplayer SDK Documentation | coherence](https://docs.coherence.io/learning-coherence/first-steps-tutorial)  
Even if you don’t download the project, it’s probably going to guide you on the right path to understanding how to setup prefabs for syncing.

Let us know how it goes!

---

<div class="post-metadata">

**Author:** ![Marvin\_Sorensen](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/marvin_sorensen/32/300_2.png) [@Marvin\_Sorensen](https://community.coherence.io/u/Marvin_Sorensen)\
**Post date:** [July 26, 2023, 3:59pm UTC](https://community.coherence.io/t/help-with-coherence-sync-prefab-player-not-syncing-variables-from-simulator-to-non-authority/338/3 "2023-07-26T15:59:57Z")

</div>

> [@ciro](#):
>
> Before I go into the post (haven’t even read it fully), I want to clarify one thing. You don’t connect Clients to Simulators. You could imagine Simulator and Clients on the same conceptual level: they are all Unity builds connecting to the Replication Server (RS).  
> Just wanted to mention it in case it was unclear.

I understand the client is connecting to the RS first, and the Simulator is just taking taking State Authority based on the client being set for Server side w/ client input.

> [@ciro](#):
>
> From the images I can’t tell much. But my hunch tells me that probably, on both instances of the editor you have the input script running, which is forcing that object to be rotated in a certain way. So even if in the second screenshot you should be using the rotation that is coming from the network (because the object is remote), you might be forcing it to a certain value every frame, so you never see it update.
> 
> To resolve this, make sure that the input for remote objects is not active. That your script(s) are not modifying values that they shouldn’t.

I don’t believe this is the case, because I’m disabling it for non-authoritative network objects. Here is the config:

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/coherence/original/1X/d8fcd57ee0a92d45621aa8d68267360299a27baa.png)

I was only mentioning the _ **SECOND CLIENT** _ in the Editor to illustrate that I would be able to inspect the values of the _ **FIRST CLIENT** _ connecting. This gives me the ability to view the network object in a non-authoritative state.

> [@ciro](#):
>
> We have a quick way to do this using the Components part of the Configuration panel (the one shown in the images). This behaviour is described on this page, specifically at this section: [Prefab Setup: CoherenceSync - Unity Multiplayer SDK Documentation | coherence](https://docs.coherence.io/get-started/prefab-setup#5.-disable-input-on-replicated-object)  
> Give it a read 🙂
> 
> I would also suggest reading through at least the first 3 sections of this tutorial: [First Steps tutorial - Unity Multiplayer SDK Documentation | coherence](https://docs.coherence.io/learning-coherence/first-steps-tutorial)  
> Even if you don’t download the project, it’s probably going to guide you on the right path to understanding how to setup prefabs for syncing.

I have scoured the documentation, and I do have the projects downloaded to refer back to for runtime & code examples.

---

<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 27, 2023, 7:26am UTC](https://community.coherence.io/t/help-with-coherence-sync-prefab-player-not-syncing-variables-from-simulator-to-non-authority/338/4 "2023-07-27T07:26:23Z")

</div>

Hmm. The setup seems correct from what I can see.

Are you using Unity’s Third Person controller from Starter Assets? With no modifications? Maybe I can create a reproduction case and make it work, and share it.

---

<div class="post-metadata">

**Author:** ![Marvin\_Sorensen](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/marvin_sorensen/32/300_2.png) [@Marvin\_Sorensen](https://community.coherence.io/u/Marvin_Sorensen)\
**Post date:** [July 27, 2023, 3:45pm UTC](https://community.coherence.io/t/help-with-coherence-sync-prefab-player-not-syncing-variables-from-simulator-to-non-authority/338/5 "2023-07-27T15:45:50Z")

</div>

That is the base of setup, but it is heavily modified at this point for my use case. It has been tailored to work with Coherence.

---

<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 28, 2023, 10:09am UTC](https://community.coherence.io/t/help-with-coherence-sync-prefab-player-not-syncing-variables-from-simulator-to-non-authority/338/6 "2023-07-28T10:09:48Z")

</div>

After some investigation, I spotted something in the project that might be the cause for issues. I want to post it too, in case.

While this setup is correct:

> [@Marvin\_Sorensen](#):
>
> I don’t believe this is the case, because I’m disabling it for non-authoritative network objects. Here is the config:
> 
> ![image](https://europe1.discourse-cdn.com/flex017/uploads/coherence/original/1X/d8fcd57ee0a92d45621aa8d68267360299a27baa.png)

I found out that Marvin also syncs the `enabled` property of those scripts. This can lead to undesirable results.

What we usually want is that input-reading scripts work on the client that has authority. If the prefab is spawned on another client, we want that script to disable (which is what the Components tab does for you).  
But if we sync the `enabled` property, the script will be turned back on because - hey the Client with authority has it enabled, so it needs to be enabled everywhere!

So turning the syncing of those properties off should be a first step to see if it solves the de-sync.

Let me know how it goes, Marvin!

---

<div class="post-metadata">

**Author:** ![Marvin\_Sorensen](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/marvin_sorensen/32/300_2.png) [@Marvin\_Sorensen](https://community.coherence.io/u/Marvin_Sorensen)\
**Post date:** [July 28, 2023, 9:30pm UTC](https://community.coherence.io/t/help-with-coherence-sync-prefab-player-not-syncing-variables-from-simulator-to-non-authority/338/7 "2023-07-28T21:30:32Z")

</div>

I’ve done some testing, and I rely on those scripts being enabled because they process logic on the State Authority ( Simulator ), as well as the Input Authority ( Client ).

So it seems I need to add logic for non-authority objects. Or maybe it would help to break out the scripts into enabled everywhere, and only enabled on State Authority. I’m doing some of that with:

```auto
if (SimulatorUtility.IsSimulator)
{
}

```

You give examples for checking Authority:

```auto
public void Update()
{
    if (coherenceSync.HasStateAuthority || coherenceSync.HasInputAuthority)
    {
        ProcessMousePosition();
    }

    if (coherenceSync.HasInputAuthority)
    {
        SendMousePosition();
    }
}

```

---

<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 29, 2023, 8:59am UTC](https://community.coherence.io/t/help-with-coherence-sync-prefab-player-not-syncing-variables-from-simulator-to-non-authority/338/8 "2023-07-29T08:59:49Z")

</div>

I see.

Yes, sometimes it can also make sense to break things into multiple scripts and leave some of them enabled, while disabling others.

Or, you can do what you did here, if breaking the logic apart is too complex or would lead to a lot of data duplication!

---

<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 31, 2023, 7:55am UTC](https://community.coherence.io/t/help-with-coherence-sync-prefab-player-not-syncing-variables-from-simulator-to-non-authority/338/9 "2023-07-31T07:55:46Z")

</div>

If you don’t mind, I’ve marked my reply that seems to contain the key info as the solution, so someone that might be searching for similar keywords can find it.

---

<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:** [August 30, 2023, 7:56am UTC](https://community.coherence.io/t/help-with-coherence-sync-prefab-player-not-syncing-variables-from-simulator-to-non-authority/338/10 "2023-08-30T07:56:48Z")

</div>

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