我正在实例化一个带有子(MoveRightBtn)和事件触发器“指针向下”的GameObject(Canvas)。 这是一个按钮,触摸时我应该移动我的播放器。但触摸时发生此错误:
尝试在没有权限的情况下发送对象命令。
UnityEngine.Networking.NetworkBehaviour:SendCommandInternal(NetworkWriter, Int32, String)
playerShoot:CallCmdMove(Single)
UnityEngine.EventSystems.EventSystem:Update()
有什么问题?
代码:
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);
}
}
播放器: http://i.stack.imgur.com/1RN1V.png
画布:http:// i .stack.imgur.com / zu8Ax.png