# Server Authorized Movement Questions

**URL:** <https://community.coherence.io/t/server-authorized-movement-questions/598>\
**Category:** Help\
**Created:** [October 15, 2024, 1:39pm UTC](https://community.coherence.io/t/server-authorized-movement-questions/598 "2024-10-15T13:39:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hzekigogebakan](https://avatars.discourse-cdn.com/v4/letter/h/958977/32.png) [@hzekigogebakan](https://community.coherence.io/u/hzekigogebakan)\
**Post date:** [October 15, 2024, 1:39pm UTC](https://community.coherence.io/t/server-authorized-movement-questions/598/1 "2024-10-15T13:39:43Z")

</div>

I did the points in the Server Authhoritive Setup section but I did not understand some points.

I wrote the parts mentioned in the documentation but I didn’t see the part about what to run and how to do it.

For example, if I have Input Authority in CoherenceInput in the script in the player, I send inputs.

Then the server, that is, the simulatorm, will take over the part of playing the character?

I created a PlayerMovementSimulator script for this and I think I need to check if there is a simulator and do something.

At this point, do I need to reach the character from the simulator script, capture the coherenceInput and move it according to the value there, if so, how do I do this?

Below I am attaching photos of the code and components including the whole setup.

```auto
using Coherence.Toolkit;
using Coherence.Toolkit.Bindings;
using System.Linq;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    private CoherenceInput _coherenceInput;
    private CoherenceSync _coherenceSync;

    private void Awake()
    {
        _coherenceInput = GetComponent<CoherenceInput>();
        _coherenceSync = GetComponent<CoherenceSync>();
        Binding positionBinding = _coherenceSync.Bindings.FirstOrDefault(c => c.Name == "position");
        positionBinding.predictionMode = Coherence.PredictionMode.InputAuthority;
        positionBinding.OnNetworkSampleReceived += DetectMisprediction;
    }

    private void DetectMisprediction(object sampleData, bool arg2, long arg3)
    {
        const float MispredictionThreshold = 3;

        var networkPosition = (Vector3)sampleData;
        var distance = (networkPosition - transform.position).magnitude;

        if (distance >= MispredictionThreshold)
        {
            transform.position = networkPosition;
        }
    }

    private void Update()
    {
        if (_coherenceSync.HasInputAuthority)
        {
            SendInputs();
        }
    }

    private void SendInputs()
    {
        Vector2 input = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
        _coherenceInput.SetAxis2D("Joystick",input);
    }

    private void ProcessInputs()
    {
        Vector2 input = _coherenceInput.GetAxis2D("Joystick");
        transform.Translate(input * Time.deltaTime * 10);
    }
}

```

```auto
using Coherence.Toolkit;
using UnityEngine;

public class PlayerMovementSimulator : MonoBehaviour
{
    private CoherenceBridge _bridge;
    private bool _isSimulator;
    private void Awake()
    {
        _bridge = FindObjectOfType<CoherenceBridge>();
        _isSimulator = _bridge.IsSimulatorOrHost;
    }

    private void Update()
    {
        if (_isSimulator)
        {

        }
    }
}

```

![image](https://europe1.discourse-cdn.com/flex017/uploads/coherence/original/1X/b3bd41096c7ee1258d0fd1f1a9156eccf9766a64.png)  
 ![image](https://europe1.discourse-cdn.com/flex017/uploads/coherence/original/1X/9c30ae4fde42dbbae090b18e59a3d1379f12975d.png)  
 ![image](https://europe1.discourse-cdn.com/flex017/uploads/coherence/original/1X/06890b03a32fa743e426e6ef69a903471d578e03.png)

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

---

<div class="post-metadata">

**Author:** ![brit](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/brit/32/34_2.png) [@brit](https://community.coherence.io/u/brit)\
**Post date:** [October 15, 2024, 2:10pm UTC](https://community.coherence.io/t/server-authorized-movement-questions/598/2 "2024-10-15T14:10:11Z")

</div>

It looks like you’re missing this block:

```auto
if (coherenceSync.HasStateAuthority || coherenceSync.HasInputAuthority)
    {
        ProcessInputs();
    }

```

Take a look at the Update function here: [Server-authoritative setup | coherence Documentation](https://docs.coherence.io/manual/authority/server-authoritative-setup#client-side-prediction)

---

<div class="post-metadata">

**Author:** ![hzekigogebakan](https://avatars.discourse-cdn.com/v4/letter/h/958977/32.png) [@hzekigogebakan](https://community.coherence.io/u/hzekigogebakan)\
**Post date:** [October 15, 2024, 2:38pm UTC](https://community.coherence.io/t/server-authorized-movement-questions/598/3 "2024-10-15T14:38:48Z")

</div>

When I add the block and run the same setup, when I start the simulator, I can control the character born with the simulator, but the character in the editor cannot control itself because it has no state authoritiy.

But isn’t this what should happen anyway, I should be able to control it only with input authority while the state authority remains on the server side?

---

<div class="post-metadata">

**Author:** ![brit](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/brit/32/34_2.png) [@brit](https://community.coherence.io/u/brit)\
**Post date:** [October 15, 2024, 3:15pm UTC](https://community.coherence.io/t/server-authorized-movement-questions/598/4 "2024-10-15T15:15:14Z")

</div>

Are you assigning Input Authority to the client?

> **[Server-authoritative setup | coherence Documentation](https://docs.coherence.io/manual/authority/server-authoritative-setup#input-authority)**

```auto
public void AssignNewInputAuthority(CoherenceClientConnection newInputOwner)
{
    var coherenceSync = GetComponent<CoherenceSync>();
    coherenceSync.TransferAuthority(newInputOwner.ClientId, AuthorityType.Input);
}

```

---

<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:** [January 13, 2025, 3:16pm UTC](https://community.coherence.io/t/server-authorized-movement-questions/598/5 "2025-01-13T15:16:11Z")

</div>

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