我正在实例化一个带有事件触发器“Pointer Down”的孩子(MoveRightBtn)的游戏对象(画布)。这是一个按钮,当我触摸它时,我应该移动我的播放器。但是当触摸时会发生此错误:
试图在没有权限的情况下为对象发送命令。
UnityEngine.Networking.NetworkBehaviour:SendCommandInternal(NetworkWriter, Int32, String)
playerShoot:CallCmdMove(Single)
UnityEngine.EventSystems.EventSystem:Update()
怎么了?
代码:
公共类 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);
}
}
播放器:http : //i.stack.imgur.com/1RN1V.png
画布:http://i.stack.imgur.com/zu8Ax.png
画布子:http: //i.stack.imgur.com/oXwTy.png