Hey guys, how do I go abouts implementing a simple highscore system. this is my scoring based code
using UnityEngine;
using System.Collections;
public class Score : MonoBehaviour
{
public GUIText JewelsText;
public GUIText WinText;
private int Jewels;
void Start ()
{
Jewels = 0;
SetJewelsText();
WinText.text = "";
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "Pickups")
{
other.gameObject.SetActive(false);
Jewels = Jewels + 1;
SetJewelsText();
}
}
void SetJewelsText()
{
JewelsText.text = "Jewels:" + Jewels.ToString();
if(Jewels >=2)
{
WinText.text = "You Collected all the jewels!";
}
}
}
I want it to so save the previous score but reset if its beaten next time round
"[...] setting it or create your own method since you have them all under the same parent object you can use GetComponentsInChildren". Sometimes, OP asks for something that could have been done easier in a different manner. So it is common to give an answer that does not answer the question but more likely provide a different (sometimes more suitable) solution to the problem. In this case, 3 years ago (time goes by so fast), I was saying that there is this or there is an answer.
– fafase