unity键盘控制

float MoveSpeed = 30f;
    // Use this for initialization
    void Start () {
    
    }
    
    // Update is called once per frame
    void Update () {
        if (Input.GetKey(KeyCode.W))
        {
            transform.Translate(Vector3.up * Time.deltaTime * MoveSpeed);
        }

        if (Input.GetKey(KeyCode.S))
        {
            transform.Translate(Vector3.down * Time.deltaTime * MoveSpeed);
        }

        if (Input.GetKey(KeyCode.A))
        {
            transform.Translate(Vector3.left * Time.deltaTime * MoveSpeed);
        }

        if (Input.GetKey(KeyCode.D))
        {
            transform.Translate(Vector3.right * Time.deltaTime * MoveSpeed);
        }
      //  transform.Translate(Vector3.left* Time.deltaTime);
        if (Input.GetKey(KeyCode.I))
        {
            transform.Rotate(Vector3.up * Time.deltaTime * MoveSpeed);
        }
    }

你可能感兴趣的:(Unity3D)