I have been taking my hand at creating a timer that countsdown when the letter ‘f’ is pressed. I only want it to count down when this letter is pressed, (EDIT: I mean this to mean that it starts a countdown when you click F, and resets either when the timer ends, or the player hits f) because I am creating a timer that when it reaches 0 the light turns off. (: I’ve tried creating a timer, so I will post it up!
private var timeLeft: float = 0;
var totalTime : float = 30;
function Awake(){
timeLeft = totalTime;
}
function Update(){
timeLeft -= Time.deltaTime;
if(timeLeft < 0)
{
light.enabled = false;
}
}
Thank you! (: Also, this is just excerpts from my code, not the entire thing. (: