unityXBOX控制第一人称人物的双向转动

来源:互联网 发布:ubuntu 查看显卡驱动 编辑:程序博客网 时间:2024/04/30 06:24
       

Vector3 euler = transform.rotation.eulerAngles;
            if (Mathf.Abs(Input.GetAxis("RightHorizontal")) > Mathf.Abs(Input.GetAxis("RightVertical")))
            {
                if ((Input.GetAxis("RightHorizontal")) >= 0.2f)
                    euler.y += 50 * Time.fixedDeltaTime;
                else if (Input.GetAxis("RightHorizontal") <= -0.2f)
                    euler.y -= 50 * Time.fixedDeltaTime;
                else return;
            }
            else if (Mathf.Abs(Input.GetAxis("RightHorizontal")) < Mathf.Abs(Input.GetAxis("RightVertical")))
            {
                if ((Input.GetAxis("RightVertical")) >= 0.2f)
                    euler.x += 30 * Time.fixedDeltaTime;
                else if (Input.GetAxis("RightVertical") <= -0.2f)
                    euler.x -= 30 * Time.fixedDeltaTime;
                else return;
            }
            else return;            
            transform.rotation = Quaternion.Euler(euler);