I am starting to learn Unity, so I made a “Clicker” kind of game that uses the keyboard instead.
My CSharp script is like this
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Score : MonoBehaviour {
public Text yourScore;
public int score;
public Button clickMe;
public int counter1;
public int purchased1;
void Start () {
score = 0;
Debug.Log(Time.fixedDeltaTime.ToString());
}
void Update () {
yourScore.text = "Money: " + score.ToString();
if (Input.GetKeyDown(KeyCode.C))
{
score++;
}
if(score>= 100&& Input.GetKeyDown(KeyCode.K))
{
purchased1++;
score = score - 100 ;
Debug.Log(purchased1);
}
if (counter1 >= 500)
{
score++;
counter1 = counter1 - 500;
}
}
void FixedUpdate()
{
counter1 = counter1 + (1 * purchased1);
}
}
The problem is that when purchased1 is a really big number (like 1000) counter1 starts to have a “backlog” of numbers. What I mean is that counter1 will stay with ex. 35000 and will slowly start substracting the 500 and adding 1 to score. Can I make it so the process of substracting is faster? I have tried putting it in FixedUpdate and Update with no luck. Thanks in advance.