我正在写一个函数,在一段时间内缓慢转动90度。到目前为止,一切工作正常,我只需要弄清楚如何使它围绕转换中心旋转一点而不是旋转。Unity3d随着时间的推移围绕一个特定的点旋转
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旋转?
在该点周围绘制一个圆并沿着该圆移动它? – Master117
这听起来像是会起作用,我对统一很陌生我使用'Quaternion.Lerp'或'Quaternion.Slerp'作为那个 –
,你可能会很好地研究[旋转](http:// docs。 unity3d.com/ScriptReference/Transform.RotateAround.html),结合'速度* deltatime',您可以添加缓解,甚至时间 –