Quantcast
Channel: Answers for "Execute coroutine in Update()"
Viewing all articles
Browse latest Browse all 11

Answer by Owen Reynolds

$
0
0
If you're just starting Unity, maybe skip coroutines completely for now. The best way to do something is a way that makes sense to you. See if this seems more obvious, counting time down to 0, then resetting: public float secsToNext=0.0f; // public lets you check it running in the Inspector Update() { secsToNext -= Time.deltaTime; // T.dt is secs since last update if(secsToNext<=0) { secsToNext = Random.Range(8.0f, 12.0f); // do thing here: } .... A coroutine automatically does the countdown for you, so runs a little faster. But if things are allready fast enough, there's no point complicating things.

Viewing all articles
Browse latest Browse all 11

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>