Unity:随着时间推移准确定位的元素

时间:2016-06-29 09:07:51

标签: unity3d unity5

我希望在每x毫秒重复的特定位置产生以相同速度移动的敌人。

Unity中update()函数的问题在于它发生在非确定性时间,所以我不能在准确的位置产生,并且我得到元素的延迟和不准确的位置。 我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

协同程序对于定期触发方法非常有用。

您可以查看this Unity forum post以查看其工作原理。

IEnumerator SpawnDelay()
{
    Spawn(); //your spawn method
    yield return new WaitForSeconds(5);
    StartCoroutine("SpawnDelay"); //Restarting the coroutine after the 5 sec delay
}