i have this script, the sanity drops all the time to 0. and i have another script which gives scares and can make the sanity meter rise.
InsanityManager.js
#pragma strict
var currentSanity : float = 20.0;
var maxSanity : float = 100.0;
var minSanity : float = 0.0;
function Update()
{
if(currentSanity <= 100)
{
currentSanity -= Time.deltaTime;
}
if(currentSanity >= 100)
{
currentSanity = maxSanity;
}
if(currentSanity <= 0)
{
currentSanity = minSanity;
}
}
function OnGUI()
{
GUI.Box(Rect(5, 5, 55, 25), "Sanity");
GUI.Box(Rect(65, 5, 55, 25), currentSanity.ToString("0") + "/" + maxSanity);
}
--------------
what i want to do is make it so that when my sanity reeches 100 it loads the death screen.
Something like this
if(currentSanity == 100)
{
Application.LoadLevel ("youdied");
}
How would i go about succesfully implementing this ??
↧