C# 4.0 如何使用Lerp缓慢旋转球形?
我需要慢慢旋转放置在航路点上的球形。它需要慢慢旋转。我如何通过Lerp实现这一点 我目前拥有的代码:C# 4.0 如何使用Lerp缓慢旋转球形?,c#-4.0,vector,unity3d,C# 4.0,Vector,Unity3d,我需要慢慢旋转放置在航路点上的球形。它需要慢慢旋转。我如何通过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; } 查看如何使用四元数 用这个例
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;
}
查看如何使用四元数 用这个例子:
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);
}
@DanPuzey
deltaTime
是完成最后一帧所需的时间,time
是游戏开始后的时间<代码>时间在游戏运行的每一秒都会变得更高,而延迟时间
的时间会根据您的fps而变化。