Hi guys,
I need some help. I don’t understand how to pass a parameter to a coroutine. I’m going about this way because I’d like to use StopCoroutine(_coRoute )
Thanks for the help!
private IEnumerator _coRoute;
private void OnEnable()
{
_coRoute = MethodMethod();
//HERE UNITY GIVES ME RED ERROR.. and I can't use _aBool
}
private void MethodMethod(bool _aBool)
{
//stuff
}
Yea I was looking at that for days and couldn’t wrap my heard around it … but now that I think about it… is this the only way to do it?
Visual Studio doesn’t throw any errors anymore. I guess this is it
Thanks!
[code=CSharp]
private IEnumerator _coRouteTrue;
private IEnumerator _coRouteFalse;
private void OnEnable()
{
_coRouteTrue = MethodMethod(true);
_coRouteFalse= MethodMethod(false);
}
private void MethodMethod(bool _aBool)
{
//stuff
}
That does match their example. Technically though, you can assign the value of the variable whenever, so you don’t actually have to have 2 IEnumerator variables unless you’re running both at the same time.
Brathnann:
That does match their example. Technically though, you can assign the value of the variable whenever, so you don’t actually have to have 2 IEnumerator variables unless you’re running both at the same time.
That’s the thing, I wasn’t able to figure out how to do that during Start(). I guess I’ll just have 2 variables … Thanks
Your coroutine’s return type needs to be IEnumerator.
Sorry I don’t understand. . .
Thanks anyways!
Oh yep, @PraetorBlue was correct and I overlooked when I said it matches their example. You should double check the link I shared to see what is different. Otherwise, it has to do with your method return type.
Brathnann:
Oh yep, @PraetorBlue was correct and I overlooked when I said it matches their example. You should double check the link I shared to see what is different. Otherwise, it has to do with your method return type.
Ohhh right… typo on my end when I was inputting the code
yea my bad.
Brathnann:
That does match their example. Technically though, you can assign the value of the variable whenever, so you don’t actually have to have 2 IEnumerator variables unless you’re running both at the same time.
And I finally understood what you meant by this … you’re right… making it a public variable would do the trick