unity:旋转停止在1到0.1度

问题描述 投票:0回答:1

当我检查检查器时,它实际上是因为它没有完全运行枚举器,所以它仍然有 1 到 0.1 未旋转

我也尝试过仔细检查ai门教程https://www.youtube.com/watch?v=kFHvdI08Cus 我检查了 Unity 论坛和 stackoverflow,但没有解决方案。

c# unity-game-engine artificial-intelligence unityscript navmesh
1个回答
0
投票

代码是这样的:

while (time < 1)
{ 
    // rotate stuff
    time += Time.deltaTime * Speed;
}

因此

time
变量增加到(可以说)1.01,但旋转代码不会再次执行,因为下一次
while
循环运行(在此协程中)时间将已经 >= 1。

解决方案:将旋转代码移到修改时间的代码下面。 这样,我们就可以确保达到结束旋转(因为当传递 1 时,Lerp 将达到结束旋转的 100%)

© www.soinside.com 2019 - 2024. All rights reserved.