Untiy3D按方向键获取值

一,如下代码

        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
        Debug.Log(h);
        transform.Translate(new Vector3(h, 0, 0) * Time.deltaTime * speed);
        transform.Translate(new Vector3(0, v, 0) * Time.deltaTime * speed);

二,transform来使用该游戏对象移动

原文地址:https://www.cnblogs.com/May-day/p/8870816.html