Instead of using a 2nd script I wrote this down:
using UnityEngine;
using System.Collections;
public class BlockSizeAndPosition : MonoBehaviour {
public int Distance;
public GameObject Player;
public GameObject[] Blocks = new GameObject[9];
private float NewRespawnTime = 4;
void Start() {
InvokeRepeating ("ChooseBlock", 2, NewRespawnTime);
}
/////The changes made are below/////
void Update() {
if (Mathf.Approximately(Mathf.Floor(Time.time / 5), Mathf.Floor(Time.time % 5)) && NewRespawnTime > 0.5f) {
NewRespawnTime -= 0.5f;
} else if (NewRespawnTime == 0.5f) {
NewRespawnTime = 0.5f;
}
Debug.Log (Time.time + ", " + NewRespawnTime);
}
/////Rest of the script/////
Now the problem is that it changes really fast to 0.5 since the updates are happening really fast and the conditions are still true, any suggestions on how to fix this?