Hello all!
Thank you for taking your time to read this. I wanted to make a game sort of like Slender. So when you pick an object up (i.e. paper), it should add the number sort of like this:
(none collected) 0/10
(1 collected) 1/10
etc.
But I wanted it to display at the top of the screen the whole time. And when the “0” or “1” (etc.) changes, it sort of leaves a faded “0” in the background (picture below). How should I fix this? Here is my code:
var AntiBiotics : int;
var ABSToWin : int = 10;
function OnTriggerEnter( other : Collider ) {
if (other.gameObject.tag == "AB") {
AntiBiotics += 1;
Debug.Log("An anti-biotic was picked up. Total anti-biotics = " + AntiBiotics);
Destroy(other.gameObject);
}
}
function OnGUI() {
if (AntiBiotics < ABSToWin) {
GUI.Box(Rect((Screen.width/2)-100, 10, 200, 35), AntiBiotics + " Anti-Biotics");
}
else {
GUI.Box(Rect((Screen.width/2)-100, 10, 200, 35), "All Anti-Biotics Retrieved!");
}
}
Thanks!
AngrySc0rpi0n