使用方法:脚本放在主摄像机(MainCamera)上。
public class TestManYou : MonoBehaviour
{
    private float w_s;
    private float a_d;
    // Start is called before the first frame update
    void Start()
    {
        
    }
    // Update is called once per frame
    void Update()
    {
        //W、S键控制 前进后退
        w_s = Input.GetAxis("Vertical");  //按下键盘上W、S键,函数值在[-1,1]的区间内连续变化。          比如按下S键,函数值在一两秒内变为-1,不按键后,很快从-1变回0
        Debug.Log("按下WS键,函数值的变化"+w_s);
        transform.Translate(Vector3.forward*Time.deltaTime*w_s);//一定注意,这里用“Vector3.forward”,而非“transform.forward”
        //A、D键控制 左右旋转
        a_d = Input.GetAxis("Horizontal");//按下键盘上A、D键,函数值在[-1,1]的区间内连续变化。
        Debug.Log("按下AD键,函数值的变化" + a_d);
        transform.Rotate(Vector3.up*Time.deltaTime*a_d*30);
    }
}
                    