- Home /
This question was
closed Nov 17, 2014 at 03:22 PM by
SaraCecilia for the following reason:
Too subjective and argumentative
Question by
Steven-1 · Nov 16, 2014 at 05:32 PM ·
coroutinecoroutinesstartcoroutine
understanding coroutines
Say I have this coroutine
protected IEnumerator DoSomething()
{
//do stuff 1
//do stuff 2
yield return new WaitForSeconds(0.75f);
}
now if I want to put some of the code in a seperate function, as far as I understand, I have to do this:
protected IEnumerator DoSomething()
{
//do stuff 1
yield return StartCoroutine(DoSomething2());
}
protected IEnumerator DoSomething2()
{
//do stuff 2
yield return new WaitForSeconds(0.75f);
}
But I find that rather weird, as I have to start a new coroutine, while I actually just want to split up the code a bit, not start a new coroutine.
Is this correct? I dunno, I just can't seem to grasp coroutines truly.
Comment
Whats your actual question? Your code appears correct.
Please provide details of the expected behaviour, and what is going wrong.
Follow this Question
Related Questions
Why doesnt my coroutine ever end? 2 Answers
Coroutines IEnumerator not working as expected 2 Answers
How to force Coroutine to finish 1 Answer
Coroutines and states 1 Answer