In my below code, random object falls with Invokerepeating() finction. But the problem is, i want repeating time to be decreased with constantly repeating value from 1.0f to 0.5f with decreasing rate of 0.05f. So that, as time passes, the object start falling more fast and game becomes hard. How to do that?
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class Poolingscript2 : MonoBehaviour {
public GameObject[] allprefabs;
public List<GameObject> bullets ;
public int listsize;
GameObject go;
// Use this for initialization
void Start ()
{
createlist ();
InvokeRepeating ("fallobject", 2.0f,1.0f);
}
void createlist()
{
allprefabs = Resources.LoadAll<GameObject> ("Prefab");
for (int i=0; i<listsize; i++)
{
foreach (GameObject allprifab in allprefabs)
{
go = Instantiate(allprifab)as GameObject;
go.SetActive(false);
bullets.Add (go);
}
}
}
GameObject temp;
void fallobject()
{
int randm = Random.Range(0,listsize);
temp = bullets.ElementAt(randm);
bullets.Remove(temp);
temp.transform.position = transform.position;
//yield return new WaitForSeconds (10.0f);
temp.SetActive(true);
}
float getdrag(float dr)
{
float dr1;
float rnd_drag = Random.Range (0.5f, 0.5f);
dr1 = rnd_drag;
return dr1;
}
public void Update()
{
}
public void addtolist(GameObject g)
{
g.SetActive (false);
bullets.Add (g);
}
}