I am creating a endless runner, I’m almost done but require to add a score system, in which each item I jump I get one point… I’ve been looking for the past two days for a tutorial on making system to keep track of Points/Score and I haven’t found anything that works with the new unity UI.
Basically I think (and hope) it would be set out that as my player collides with an invisible object above the item I am jumping over, I get one point. I’d also like to a highscore system, if you guys know much about all that.
I am hoping, someone here can direct me to a tutorial in C# (Or easily convertible) or send some sample script with the set-up explained…
Sorry for asking for help without even having some script, but I’m kind of clueless how to start.
Do you mean, with a database, so you can get the value for another time?
Otherwise, implementation of a score variable with the unity UI is pretty straight forward:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class ClickScore : MonoBehaviour {
Text text;
int score = 0;
void Start () {
text = transform.Find("Text").GetComponent<Text>();
}
void Update () {
if (Input.GetMouseButtonDown(0)) {
score++;
text.text = "SCORE: "+score;
}
}
}
Example enclosed as unityPackage. I used “clicking” to get a score, rather than jumping, for brevity’s sake.