unity 角度旋转限制,使用四元数方式

angle += state.ThumbSticks.Left.Y * 25.0f * Time.deltaTime;//俯仰角

var kk = Mathf.Clamp(angle, -30, 30);
Quaternion _kk = new Quaternion();
_kk = Quaternion.AngleAxis(kk, Vector3.left);//上下旋转

angle2 += state.ThumbSticks.Left.X * 25.0f * Time.deltaTime;//俯仰角
Quaternion _kk2 = new Quaternion();
_kk2 = Quaternion.AngleAxis(angle2, Vector3.up);//左右旋转

var gg = _kk * originRotation;
My.transform.localRotation = _kk2 * gg;

文章来自:http://www.cnblogs.com/Study02/p/5549145.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3