2

I'm instantiating a GameObject (a Canvas) that have a child (MoveRightBtn) with a Event Trigger "Pointer Down". It is a button that when touched I should move my player. But when touched occurs this error:

Trying to send command for object without authority.

UnityEngine.Networking.NetworkBehaviour:SendCommandInternal(NetworkWriter, Int32, String)
playerShoot:CallCmdMove(Single)
UnityEngine.EventSystems.EventSystem:Update()

What is wrong?

Code:

public class playerShoot : NetworkBehaviour {

public GameObject buttons;

void Start () {
    NetworkServer.SpawnWithClientAuthority ((GameObject)Instantiate (buttons), connectionToClient);
}

void Update () {

}

[Command]
void CmdMove(float horizontalInput){
    GetComponent<Rigidbody2D>().velocity = new Vector2(1f, 1f);
}

}

Player: https://i.stack.imgur.com/1RN1V.png

Canvas: http:// i .stack.imgur.com/zu8Ax.png

Canvas child: https://i.stack.imgur.com/oXwTy.png

user3071284
  • 6,955
  • 6
  • 43
  • 57
Erie Dias
  • 21
  • 6

0 Answers0