- Home /
 
 
               Question by 
               DubstepDragon · Jul 24, 2013 at 02:40 PM · 
                c#gameincreaserate  
              
 
              Intensifying rate over time...
I have a script that spawns cubes every 0.3 seconds. I want there to be a sense of progression in my game, so I want the rate of spawning to increase by 0.1 every ten seconds. How can I do this?
Thanks in advance! (c# plz!) My script is here:
 using UnityEngine;
 using System.Collections;
 
 public class Cubes : MonoBehaviour {
     
     public float delay = 0.1f;
     public GameObject cube;
     
     void Start () {
         InvokeRepeating("Spawn", delay, delay);
     }
     
     void Spawn () {
         Instantiate(cube, new Vector3(Random.Range(-7.3f, 7.3f), 10, 0), Quaternion.identity);
     }
 }
 
               :D
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Sycohazza · Jul 24, 2013 at 02:52 PM
One way to do this is:
 public float delay = 0.1f;
     private float lastIncreased;
     private float timeDelay = 10;
     
     void Update () {
         if(Time.time > timeDelay + lastIncreased){
             lastIncreased = Time.time;
             delay += 0.1f;
         }
     }
 
               Hope this helps!
Sycohazza
Your answer
 
             Follow this Question
Related Questions
Increasing spawn rate over time 0 Answers
Unity: C#: Eyes look at mouse: HELP!! 3 Answers
Changing gravity direction... 5 Answers
I need help with a script(brauche hilfe mit einen Script) 0 Answers
A node in a childnode? 1 Answer