Unity Networking: Client cant move object but sees everything server does

I am trying to get a simple networking game running in.

What I try to achieve: A 3D object is moved with WASD movement, either server or client can do this and both see the same movement changes.

What I am seeing now is the following: Server can move the object via WASD perfectly fine, the client sees every movement just as expected. Now on the client side I try to move the object via WASD…this works locally, but the server does not see any changes. Once the server moves the object again, the object on the client side gets translated to the position the server sees.


I thought setting “network authority” to “local player authority” would resolve my problem but it didnt.
Short version what I did:


  • Create a new 3D object
  • Add NetworkIdentity to it, set “Local Player Authority” to true
  • Add NetworkTransform
  • Add script that moves item via WASD

Content of my script:

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.J))
        {
            Vector3 position = this.transform.position;
            position.x = position.x - speed;
            this.transform.position = position;
        }
        if (Input.GetKeyDown(KeyCode.L))
        {
            Vector3 position = this.transform.position;
            position.x = position.x + speed;
            this.transform.position = position;
        }
        if (Input.GetKeyDown(KeyCode.I))
        {
            Vector3 position = this.transform.position;
            position.y = position.y + speed;
            this.transform.position = position;
        }
        if (Input.GetKeyDown(KeyCode.K))
        {
            Vector3 position = this.transform.position;
            position.y = position.y - speed;
            this.transform.position = position;
        }
    }

Could it be that changing a transform via script needs some kind of trigger to send changes over network? If so, why does work out of the box for the server and not for the client?

You have to send the position updates as a command, not sure if it works dont really have time to test but i hope itll help, and yes this is very late lol

    void Update()
         {
             // I added a isLocalPlayer check, remove it if its not supossed to be here, what it basically does is when one client does one of these actions it won't register it as if all other clients did it as well
             if(!isLocalPlayer) return;

             if (Input.GetKeyDown(KeyCode.J))
             {
                 CmdChangeCubePos(new Vector3(-1,0,0);
             }
             if (Input.GetKeyDown(KeyCode.L))
             {
                 CmdChangeCubePos(new Vector3(1,0,0);
             }
             if (Input.GetKeyDown(KeyCode.I))
             {
                 CmdChangeCubePos(new Vector3(0,1,0);
             }
             if (Input.GetKeyDown(KeyCode.K))
             {
                 CmdChangeCubePos(new Vector3(0,-1,0);
             }
         }
    
    // The [Command] tells the server/client its a command meaning it gets sent from the client to the server
    
    [Command]
    void CmdChangeCubePos(Vector3 change)
    {
        Vector3 position = this.transform.position;
        position = position + change * speed
        this.transform.position = position;
    }