The counter counts perfectly up until the first bump. After this it starts to add about 4-5 "points" instead of just 1.
using UnityEngine;
using System.Collections;
public class GameController : MonoBehaviour
{
public GUIText scoreText;
public int score;
// CONVERT FLOAT TO INT?
void Start (){
score = 0;
StartCoroutine (FeetScoreCounter());
}
// STARTS COUNTING AFTER WAITFORSECONDS
IEnumerator FeetScoreCounter() {
yield return new WaitForSeconds (1);
InvokeRepeating("scoreCounter", 2, 1);
}
// FOR EACH 5 SECONDS; score++ ???
void Update () {
scoreText.text = score + " ft";
// StartCoroutine (FeetScoreCounter());
}
void scoreCounter () {
score += 1;
StartCoroutine (FeetScoreCounter());
score ++;
}
}
I want my counter to start counting when the game starts, to show how far up the balloon is. I am incapable of seeing why my code just randomly adds a whole lot more over time. Care to help?