Hey Guys,
I wondering how you would be able to make a Pauseable-Timer Unity.
I have a flashlight toggle script here:
var flashlight : boolean;
function Update () {
if (Input.GetButtonDown("Fire2")) {
GetComponent(Light).enabled = !GetComponent(Light).enabled;
}
if (GetComponent(Light).enabled)
{
flashlight = true;
Debug.Log("Flashlight On");
}else{
flashlight = false;
Debug.Log("Flashlight Off");
}
}
I need to make a battery as a form as a GUIBox for the flashlight.
At the start of the game, it would start at 100% and drop down to 0% in 1 second intervals.
The player can switch off the flashlight which would pause the timer. (Time.deltaTime
)
I know I could use Time.deltaTime
but I can’t find a way to pause it.
(P.S. I also need the player to find battery’s scattered along an asylum or house which would increase their battery life in the flashlight.)