How can I stop my score from adding temporally for a certain amount of seconds? My score system uses Time, but I’ve had too many problems with using Time.timeScale = 0, so I would like an answer that doesn’t involve that(unless it’s the only way). So how can I do this? EDIT: I’ve made changes to the script, the new one posted is not the same as it was before. Just a heads up to the people who read this before. Here’s my(New) script:
float playerScore = 0;
public Font MyFont;
public bool On = true;
public bool Off = false;
ControllerScript player;
void Start()
{
player = GetComponent<ControllerScript>();
}
void Update () {
if(On == true && Off == false)
playerScore += Time.deltaTime;
}
public void IncreaseScore(int amount)
{
playerScore += amount;
}
void OnTriggerEnter2D(Collider2D col)
{
// If the colliding gameobject is Object...
if(col.gameObject.tag == "Item1")
{
On = false;
Off = true;
}
}
void OnDisable()
{
PlayerPrefs.SetInt ("Score", (int)(playerScore * 5));
PlayerPrefs.SetString("PlayerName", "High Score");
PlayerPrefs.Save ();
Debug.Log("Saved, Yes!");
}
void OnGUI()
{
GUI.skin.font = MyFont;
GUI.contentColor = Color.white;
GUI.Label (new Rect(10, 10, 200, 30), "Score: " + (int)(playerScore * 5));
}
}
All I really need to know is how to stop it, I can manage the seconds part.