----创建一个cube,加入代码
#pragma strict function Start () { } function Update () { transform.Translate(Input.GetAxis("Horizontal"),0, Input.GetAxis("Vertical")); }
--------修改移动速度
#pragma strict function Start () { } var speed = 5.0; function Update () { var x = Input.GetAxis("Horizontal")*Time.deltaTime*speed; var z = Input.GetAxis("Vertical")*Time.deltaTime*speed; transform.Translate(x,0,z); }
时间: 2024-10-14 15:12:03