- Home /
Help with sanity script loading death screen
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 ??
Answer by thaiscorpion · Dec 18, 2013 at 04:42 PM
It the part of your code, just add it in there and that should work fine:
if(currentSanity >= 100){
currentSanity = maxSanity;
Application.LoadLevel ("youdied");
}
Your answer
Follow this Question
Related Questions
Problems using NGUI for in-game options sliders 0 Answers
How to make text appear when moving next to an object? 3 Answers
Unity3D Game Time 1 Answer
create a GuiSkin 2 Answers
GameObjects name As GuiText 2 Answers