您的位置:首页 > 移动开发 > Unity3D

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

2017-07-11 09:30 375 查看
       


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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: