ok so as soon as i press “p” to increase the difficulty, difficulty increases to 2 and the timer sets to 0. i already tried making it a float but that didn’t change anything?
var xPos : float = Random.Range(-50,50);
var yPos : float = Random.Range(-50,50);
var zPos : float = Random.Range(69,9001);
var spawnPos : Transform;
var spawnObject : GameObject;
var timer : float = 1;
var difficulty = 1;
var score = 0;
var countScore = 1;
function Start () {
Invoke("CustomUpdate",timer);
}
function CustomUpdate () {
Invoke("CustomUpdate",timer);
xPos = Random.Range(-50,50);
yPos = Random.Range(-50,50);
zPos = Random.Range(69,9001);
spawnPos.position.x = xPos;
spawnPos.position.y = yPos;
spawnPos.position.z = zPos;
Instantiate(spawnObject,spawnPos.position,spawnPos.rotation);
if(countScore == 1){
score += 1;
}
}
function Update () {
if(Input.GetKeyDown("o")){
if(difficulty >= 2){
difficulty -= 1;
}
}
if(Input.GetKeyDown("p")){
if(difficulty <= 9){
difficulty += 1;
}
}
timer = 1 / difficulty;
}
function Message () {
countScore = 0;
}
function OnGUI () {
GUI.Label (Rect (10, 10, 200, 40),"score:" + score);
GUI.Label (Rect (10, 60, 200, 40),"difficulty" + difficulty);
}