1

我需要慢慢旋转放置在航点上的球形。它需要慢慢旋转。我怎样才能用 Lerp 实现这一目标?

我目前拥有的代码:

if(!isWayPoint5)
{
    //here i"m using turn by using rotate but i needed rotate 
    //slowly is same as turns train in track.
    transform.Rotate(0,0,25);
    isWayPoint5 = true;
}
4

1 回答 1

2

在 wiki 站点上查看如何使用 Quaternion.Lerp 。

使用该示例:

public Transform from = this.transform;
public Transform to = this.transform.Rotate(0,0,25);
public float speed = 0.1F; //You can change how fast it goes here
void Update() {
    transform.rotation = Quaternion.Lerp(from.rotation, to.rotation, Time.time * speed);
}
于 2013-06-26T09:49:31.630 回答