移动分为获取指令移动两步
获取指令
方法一:
Input.GetAxis("Horizontal");
Input.GetAxis("Vertical");
第一种过去水平、垂直两个方向的按键指令(上下左右和WASD),然后返回值一个数(不固定,与你按得状态似乎有关系)。
方法二:
Input.GetKey(KeyCode.space)获取空格
获取按键,具体可查———>https://blog.csdn.net/poem_of_sunshine/article/details/39699285
移动方法
方法一:
this.gameObject.transform.Translate(H, V,0, Space.World);
最后一个值为以哪个坐标轴为标准,Space.World为世界坐标系,不填或Space.Self以自己相对坐标,Camera.main.transform为相机的相对的坐标系
方法二:
this.gameObject.transform.position+= this.gameObject.transform.forward;
其中right为x轴,up为Y轴,forward为z轴
方法三:
Vector3 move=new Vector3<