- Home /
Question by
Jombobo · Sep 04, 2013 at 01:14 PM ·
functionwaitforseconds
Can't have two WaitForSeconds in one function?
I create a function like this:
private IEnumerator Test(){
//do something
yield return new WaitForSeconds(0.3f);
//don something
yield return new WaitForSeconds(2.0f);
}
it can't work. may i have to do it like this?
private IEnumerator Test1(){
//do something
yield return new WaitForSeconds(1.0f);
}
private IEnumerator Test2(){
StartCoroutine(Test1());
yield return new WaitForSeconds(1.0f);
}
void Update(){
StartCoroutine(Test2());
}
this is a terrible solution
Comment
What do you mean by it can't work? Using
StartCoroutine(Test())
should work without problem. Have you tried to put Debug.Log calls before/after the yield statements?
You test function should work properly if you start it using StartCoroutine(Test()) like ArkaneX said. I've done it myself several time.
Your answer

Follow this Question
Related Questions
Calling IEnumerators 1 Answer
How do i make my canvas appear for few seconds only? 0 Answers
Use yield WaitForSeconds to delay mouseover on a gameObject? (JS) 1 Answer
Checking variable each frame to increase another variable every few seconds 1 Answer
Loop a function, once per second, X number of times 1 Answer