Ive been using a simple on/off script with my in game flashlight but now Im trying to implement a battery effect and have the flashlight on a countdown timer while switched on. I’ve updated my original script but the timer is counting down way too fast and I cant figure why?
var Battery : int = 100;
var Batterytext : GUIText;
function Update ()
{
Batterytext.text = " Flashlight " + Battery + " % ";
if (Input.GetKeyDown("f"))
{
if (light.enabled == true)
light.enabled = false;
else
light.enabled = true;
}
if (light.enabled == true)
{
Battery -= Time.deltaTime;
}
}
I did try another method using yield WaitForSeconds but had similar issues.
The on/off function still works and pauses the countdown (if your quick enough…lol) But it doesn’t count down in seconds as Id planned it to.
Any suggestions guys ???