Hello, I have two simple questions 1: How do I set a timer and activate a script when the timer reaches a certain value? 2: How do I add a simple scoring system (when ever thing A happens, Increase Score by X value and register on the GUI)? Thanks
Try this:
var myScore = 0;
var DelayTime = 10; // 10 seconds before activating function
function Start(){
Invoke("myFunction", DelayTime);
}
function OnGUI(){
GUI.Label(Rect(0,0, 200, 30), "Score: " + myScore);
}
function SomethingAppears(){
myScore++;
}
For timed events, use Invoke:
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.Invoke.html
Herman Tulleken has already answered your first question so i wont worry about that. As for your second question i would set a static variable that stores the score value.
I am not sure on the exact details on your game but something like this should work
//put this script in the object that calls the point scoring event
var pointAmount : float = 10;
//put this somewhere in the script so that it only runs when the point scoring event occurs
score += pointAmount;
Just make sure that a static "score" is declared and set the HUD to draw the value of score.
Te Tme class offers a lot of functionality relating to time...