Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

How would you guys go about making timers?

$
0
0
How would you guys go about making timers?

For instance, I have a lot of things that need to happen only a certain amount of time after an object is instantiated, and if and when it does happen, I would imagine that checking the time.time every frame is bad.

What I'm doing right now is (paraphrased)

Code (CSharp):
  1. private float birthtime;
  2.  
  3. void Start() { birthtime = Time.time +3f; }
  4.  
  5. void Update(){
  6. if (Time.time > birthtime){
  7. doWhatever();
  8. }
  9. }
So that will doWhatever after 3 seconds,...

How would you guys go about making timers?

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



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