I think you don't need to explicitly StartCoroutine when yielding another coroutine, just 'yield return SomeOtherRoutine()' should behaviour as intended in the video.
Great to see another one of these! Found it really useful, too. I confess that I wasn't quite seeing the point until you connected it to the silo launch sequence, and then it clicked for me. Thank you!
Yeah. I've used them occasionally and need to learn more about them. Definitely more complex with some pitfalls, but a better overally solution in many or most cases.
Thanks that was really useful. Didnt know you could also yield return other coroutines. This is also helpful to break large coroutines into smaller pieces.
The method you show with Actions passed to Coroutines as a pattern is called a *Callback* It is used in many languages, but most notably it was used in javascript, where it got used to such excess, that they invented the term "callback hell", because once you nest it too deep, the program can get really hard to read. I liked your suggestion to create wrapping coroutines that calls many other coroutines very much.
Problem is when I put my main coroutine into update, it keeps repeating them, and when i use a boolean to run it once, it only runs each coroutine for a single frame and then stops without actually completing the coroutine despite me putting the return value to a boolean that only turns true once the coroutine has reached its destination.
@@OneWheelStudio Booleans are tricky when you calling coroutines across components. I did some more digging and found an easier way that worked well. Since I only wanted to proceed when all the coroutines were complete, I just `yield return` them one after the other Coroutine cA = StartCoroutine(whatever.DoThis()); Coroutine cB = StartCoroutine(banana.DoThat()); yield return cA; yield return cB; This works great because no matter which one will end first, it will always take as much time as the longest one to execute. What do you think?
@@palanolho82 Somehow in my head I was imagining something more complex, or I was just being dumb. 🤷♂ Your solution totally makes sense. Its clean and simple. Looks good to me.
I definitely think you can use Async functions for this type of functionality, but that can open a new can of worms for users. I want to cover Async functions, but it is a large topic and one that's easy to mess up.
The real question is though, how do you start 3 coroutines at the same time with varying durations which you can not know beforehand and then yield until all are finished.
You could have a wrapper coroutine for each coroutine. The wrapper takes in an action that invokes a function that counts how many coroutines have finished. This might be a bit Jacky, but it could give a handle on tracking how many have completed.
This kind of use case for coroutines never really came up for me in my projects but it got me wondering how to accomplish it. Yeesh! There has to be a better way than what I'm doing in this Gist: gist.github.com/nikescar1/65255cacc6450c2c464802f413a87a83 By the time I added OnFinish messaging to everything, it's not that pretty. Does seem to work though.
I also gave an example of how to "return" values from coroutines using an Action. The inability for coroutines to return values is always on lists of why to avoid coroutines.
I think you don't need to explicitly StartCoroutine when yielding another coroutine, just 'yield return SomeOtherRoutine()' should behaviour as intended in the video.
You got it, no need to call StartCoroutine() when yielding another coroutine.
Yep. Totally missed that. Keeps it even cleaner. Thanks for pointing this out.
Great to see another one of these! Found it really useful, too. I confess that I wasn't quite seeing the point until you connected it to the silo launch sequence, and then it clicked for me. Thank you!
Recently I have moved away from Coroutines and have started using async, await, and Tasks. Makes things a lot easier from a readability standpoint.
Yeah. I've used them occasionally and need to learn more about them. Definitely more complex with some pitfalls, but a better overally solution in many or most cases.
This saved my bacon, thanks man.
That was very help. Clear and good details. Thanks. Have a wonderful day
Thanks that was really useful. Didnt know you could also yield return other coroutines. This is also helpful to break large coroutines into smaller pieces.
The method you show with Actions passed to Coroutines as a pattern is called a *Callback*
It is used in many languages, but most notably it was used in javascript, where it got used to such excess, that they invented the term "callback hell", because once you nest it too deep, the program can get really hard to read.
I liked your suggestion to create wrapping coroutines that calls many other coroutines very much.
Incredibly useful. Though after hearing the word so many times, I don't think "coroutine" means anything to me anymore, lol.
Wow! This is crazy useful, and much cleaner :D
Thanks for the all the kind comments. I'm glad you're finding some of the videos useful!
you dont need to do ```yield return StartCoroutine(MyMethod())```, you can just do ```yield return MyMethod()```
Such a good video thanks!
Problem is when I put my main coroutine into update, it keeps repeating them, and when i use a boolean to run it once, it only runs each coroutine for a single frame and then stops without actually completing the coroutine despite me putting the return value to a boolean that only turns true once the coroutine has reached its destination.
@OneWheelStudion how would you go about checking if multiple coroutines that are running in parallel has all finished?
thanks in advance
To be honest I’d probably fall back on using Booleans. I’d love to know if there is a better way.
@@OneWheelStudio Booleans are tricky when you calling coroutines across components.
I did some more digging and found an easier way that worked well.
Since I only wanted to proceed when all the coroutines were complete, I just `yield return` them one after the other
Coroutine cA = StartCoroutine(whatever.DoThis());
Coroutine cB = StartCoroutine(banana.DoThat());
yield return cA;
yield return cB;
This works great because no matter which one will end first, it will always take as much time as the longest one to execute.
What do you think?
@@palanolho82 Somehow in my head I was imagining something more complex, or I was just being dumb. 🤷♂
Your solution totally makes sense. Its clean and simple. Looks good to me.
Actually theres Async Await systems for that if i am not wrong
I definitely think you can use Async functions for this type of functionality, but that can open a new can of worms for users. I want to cover Async functions, but it is a large topic and one that's easy to mess up.
The real question is though, how do you start 3 coroutines at the same time with varying durations which you can not know beforehand and then yield until all are finished.
You could have a wrapper coroutine for each coroutine. The wrapper takes in an action that invokes a function that counts how many coroutines have finished. This might be a bit Jacky, but it could give a handle on tracking how many have completed.
This kind of use case for coroutines never really came up for me in my projects but it got me wondering how to accomplish it.
Yeesh! There has to be a better way than what I'm doing in this Gist: gist.github.com/nikescar1/65255cacc6450c2c464802f413a87a83
By the time I added OnFinish messaging to everything, it's not that pretty. Does seem to work though.
I also gave an example of how to "return" values from coroutines using an Action. The inability for coroutines to return values is always on lists of why to avoid coroutines.
Oh! I like that idea. Hadn’t thought of that use.
@@nikescar Agreed. Coroutines produce some serious spaghetti and callback hell. UniTask handles this well & has been my goto for a long time now.
Neat.
I prefer UniTask
Bro your voice sounds a lot like WackyJacky101's
Now if only our sub counts were more alike ;)