FPS角色旋转移动控制

梦想游戏人
目录:
Unity
 //move controll
        bool isMove = false;
        if (Input.GetKey(KeyCode.W))
        {
            transform.Translate(Vector3.forward * _moveSpeed);
            isMove = true;
        }
        if (Input.GetKey(KeyCode.S))
        {
            transform.Translate(Vector3.back * _moveSpeed);
            isMove = true;
        }
        if (Input.GetKey(KeyCode.A))
        {
            transform.Translate(Vector3.left * _moveSpeed);
            isMove = true;
        }
        if (Input.GetKey(KeyCode.D))
        {
            transform.Translate(Vector3.right * _moveSpeed);
            isMove = true;
        }
        animation.SetBool("IsMoving", isMove);
        //  Vector3 mov = new Vector3(Input.GetAxis("Horizontal"), 0f,
        //  Input.GetAxis("Vertical"));
        //  GetComponent<Rigidbody>().MovePosition(transform.position + mov);

        //rotation controll
        float y = Input.GetAxis("Mouse X");
        if (y != 0)
        {
            transform.Rotate(0, _rotationSpeed * y + transform.rotation.y, 0);
        }
Scroll Up