Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 如何使用Lerp缓慢旋转球形?_C# 4.0_Vector_Unity3d - Fatal编程技术网

C# 4.0 如何使用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; } 查看如何使用四元数 用这个例

我需要慢慢旋转放置在航路点上的球形。它需要慢慢旋转。我如何通过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;
}

查看如何使用四元数

用这个例子:

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而变化。