hi again, sorry for questions. how can I put delay between code lines ? for example I want my upper codes start with some delay
there is any way ?
thanks
This may work for you.
thanks but it isn’t what I want ![]()
Use coroutines instead. http://unity3d.com/support/documentation/ScriptReference/index.Coroutines_26_Yield
To put more simple.
Make a custom function, put your code in it which you like to delay, and assign a ‘yield’ command to every line you want to delay. You can then call the function from Update.
I don’t see how Suicine’s suggestion couldn’t be applied.
Here’s an example of using coroutines for this purpose.
private void DoSomething()
{
statement1;
statement2;
}
If you want to insert 2 seconds delay before calling statement1 and 1 second delay between calling statement1 and statement2, you can do the following:
private void DoSomething()
{
StartCoroutine(coDoSomethingElse());
}
IEnumerator coDoSomethingElse()
{
yield return new WaitForSeconds(2.0f);
statement1;
yield return new WaitForSeconds(1.0f);
statement2;
}