一個過程中,我不得不放棄的過程中發生的延遲,這是我在更新功能正在呼叫。 我也試過CoUpdate解決方法。這裏是我的代碼: -時間延遲了在Unity 3D
function Start()
{
StartCoroutine("CoStart");
}
function CoStart() : IEnumerator
{
while(true)
{
yield CoUpdate();
}
}
function CoUpdate()
{
//I have placed the code of the Update().
//And called the wait function wherever needed.
}
function wait()
{
checkOnce=1; //Whenever the character is moved.
yield WaitForSeconds(2); //Delay of 2 seconds.
}
當第三方控制器(這是另一個對象)移出邊界時,我必須移動一個對象。我在代碼中包含「收益率」。但是,發生的問題是:當我在Update()中給出代碼時移動的對象正在移動,但並未停止。它正在上下移動。我不知道發生了什麼!有人可以幫忙嗎?拜託,謝謝。
您應該添加有關如何將物體移動的一些信息。到目前爲止,我看不出使用協程和對象移動之間的關係。順便說一句,我不認爲這是你的問題的正確方法,看看它是多麼令人費解。 – Elideb 2012-01-03 13:49:28
使用IEnumerator函數,您可以將延遲放在具有yield WaitForSeconds(n)的那些函數中。 – 2014-11-06 03:13:40