我需要慢慢旋转放置在航路点上的球形。它需要缓慢旋转。我怎样才能用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;
}
答案 0 :(得分:2)
查看如何在the wiki-site.
上使用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);
}