求大神帮忙

Anglebabyqq 2019-03-06 02:44:36
public enum RotationAxes { MouseXandY = 0, MouseX = 1, MouseY = 2 } public RotationAxes axes = RotationAxes.MouseXandY; public float sensitivityHor = 9.0f; public float sensivityVert = 9.0f; public float minimumVert = -45.0f; public float maximumVert = 45.0f; private float _rotationX = 0; void Start () { Rigidbody body = GetComponent<Rigidbody>(); if (body != null) body.freezeRotation = true; } // Update is called once per frame void Update () { if (axes == RotationAxes.MouseX) { transform.Rotate(0, Input.GetAxis ("MouseX") * sensitivityHor, 0); } else if (axes == RotationAxes.MouseY) { _rotationX -= Input.GetAxis("MouseY") * sensivityVert; _rotationX = Mathf.Clamp(_rotationX, minimumVert, maximumVert); float rotationY = transform.localEulerAngles.y; transform.localEulerAngles = new Vector3(_rotationX, rotationY, 0); } else { _rotationX -= Input.GetAxis("MouseY") * sensivityVert; _rotationX = Mathf.Clamp(_rotationX, minimumVert, maximumVert); float delta = Input.GetAxis("MouseX") * sensitivityHor; float rotationY = transform.localEulerAngles.y + delta; transform.localEulerAngles = new Vector3(_rotationX, rotationY, 0); } }一直狂转不停求解决
...全文
57 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

8,301

社区成员

发帖
与我相关
我的任务
社区描述
游戏开发相关内容讨论专区
社区管理员
  • 游戏开发
  • 呆呆敲代码的小Y
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧