Getting a coroutine to play on if(bool true) and loop even if(bool false)

This seems simple, but some reason I can’t figure it out. I want a coroutine to play if an if statement returns true and keep playing if it returns false, but currently it simply turns the coroutine on and off.

How can I go about fixing this?

(I’m writing this in C#)

Correct me if i’m wrong but aren’t you basically saying you want the coroutine to run if true and if false

In other words, have the coroutine running regardless of the outcome of the conditional evaluation? That doesn’t make sense. Perhaps you mean the coroutine should only start if (something is) true, and continue running only if (something is) false?

Consider creating a field called

bool IsCoroutineRunning

to manage your states/conditionals. That’s the best I can suggest without knowing what you want to happen in your code.

That’s actually exactly what I meant, thanks.