2021-04-11

制作小地图俩种移动代码
1.人物移动代码
void Update()
{
float v = Input.GetAxisRaw(“Vertical”);
float h = Input.GetAxisRaw(“Horizontal”);//复制不要手打
transform.Translate(new Vector3(h, 0, v) * speed * Time.deltaTime);
}
}
2.
void Update () {
if (Input.GetKeyDown(KeyCode.W))
{
this.gameObject.transform.position += transform.forward;
}
if (Input.GetKeyDown(KeyCode.S))
{
this.gameObject.transform.position -= transform.forward;
}
if (Input.GetKeyDown(KeyCode.A))
{
this.gameObject.transform.position -= transform.right;
}
if (Input.GetKeyDown(KeyCode.D))
{
this.gameObject.transform.position += transform.right;
}
}
}

上一篇:移动的盒子


下一篇:ADB事件大全