一个过程中,我不得不放弃的过程中发生的延迟,这是我在更新功能正在呼叫。 我也试过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