Hello everyone!
I was just wondering how to make text appear for, let’s say, 2 seconds. My goal is to try to make a Slenderman-like game. So when you click the page (In my case it is an Anti-Biotic) it will say “1/10 Anti-Biotics Retrieved” and then will disappear after 2 seconds. Here is my code:
#pragma strict
@script RequireComponent( AudioSource )
var AntiBiotics : float = 0;
var ABsToWin : int = 10;
var paperSound : AudioClip;
var isCollected : boolean = false;
function Start() {
AntiBiotics = 0;
}
function OnMouseDown() {
isCollected = true;
AntiBiotics += 1;
audio.PlayOneShot(paperSound);
//Destroy(this.gameObject);
}
function OnGUI() {
if(isCollected == true) {
for
GUI.Label (Rect( (Screen.width * 0.5), (Screen.height * 0.5), 50, 25), AntiBiotics + " / " + ABsToWin);
}
}
Thanks!
-AngrySc0rpi0n