我正在寫一個函數,在一段時間內緩慢轉動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',您可以添加緩解,甚至時間 –