duck

duck

Nov 2nd, 2010
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.35 KB | None | 0 0
  1.  
  2. float numberOfConcurrentItems = 100;
  3. float lifeSpan = 5;   // in seconds
  4. float spawnPeriod;
  5. float nextEmitTime;
  6.  
  7. void Start() {
  8.     nextEmitTime = Time.time;
  9.     spawnPeriod = 1.0f / ( numberOfConcurrentItems / lifeSpan );
  10. }
  11.  
  12. void Update() {
  13.     if (Time.time > nextEmitTime)
  14.     {
  15.         nextEmitTime += spawnPeriod;
  16.         Emit();
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment