【发布时间】:2016-09-09 18:42:26
【问题描述】:
我正在编写一个函数,它会在一段时间内缓慢旋转 90 度。到目前为止一切正常,我只需要弄清楚如何让它围绕一个点旋转而不是围绕变换中心旋转。
protected bool _isRotating = false;
public IEnumerator RotateWithEasing(GameHelper.Axis axis, Vector3 isolatedAxisPoint, float inTime)
{
if(_isRotating)
{
yield break;
}
_isRotating = true;
var degrees = this.GetDegreesFromAxis(axis);
Quaternion fromAngle = transform.rotation;
Quaternion toAngle = Quaternion.Euler(transform.eulerAngles + degrees);
for (float t = 0f; t < 1f; t += Time.deltaTime / inTime)
{
transform.rotation = Quaternion.Lerp(fromAngle, toAngle, t);
yield return null;
}
_isRotating = false;
}
谁能帮我指出正确的方向,我该如何修改它以使其围绕指定的isolatedAxisPoint 旋转?
【问题讨论】:
-
围绕该点画一个圆圈并沿该圆圈移动?
-
这听起来可行,我是 Unity 新手,我会为此使用
Quaternion.Lerp或Quaternion.Slerp -
你可能会很好地查看rotate around,结合
speed * deltatime,你可以增加轻松甚至时间 -
我看看我今天晚些时候是否有时间提供更详尽的答案;)
标签: c# unity3d interpolation