Quantcast
Channel: Questions in topic: "loops"
Viewing all articles
Browse latest Browse all 184

How to make loop with call to IEnumerator actually pause?

$
0
0
Hello all, I am calling my function enterFlightMode which I am trying to make last ten seconds. 1 second per iteration. Heres the code. IEnumerator oneSec() { yield return new WaitForSeconds (1.0f); } void enterFlightMode() { Debug.Log ("Entered Flight mode"); for (int i = 10; i > 0; i--) { flightText.guiText.text = "FLY! " + i; StartCoroutine( "oneSec" ); } flightText.guiText.text = ""; flightEnabled = false; jumping = true; Debug.Log ("Exited Flight mode"); } Essentially I want the two Debug.Log statements to execute 10 seconds apart; Each second changing my guiText. I hope this is enough information let me know if you guys need more. Thanks in advanced P2 PS. I have tried a simple function call without StartCoroutine, but im not too sure of the difference

Viewing all articles
Browse latest Browse all 184

Trending Articles



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