Hey all, so I want a timer in my game that stops when the player reaches a trigger.
I can do a timer okay but I can’t link it up to a trigger any ideas?
Thanks
Hey all, so I want a timer in my game that stops when the player reaches a trigger.
I can do a timer okay but I can’t link it up to a trigger any ideas?
Thanks
Something like this should work:
public bool stopTimer {get; set;}
float timer = 5;
void Update()
{
if(timer > 0 && !stopTimer)
{
timer -= Time.deltaTime
}
}
void OnTriggerEnter(Collider col)
{
if(col.gameObject.tag == "player") // requires the tag "player" on your player character
stopTimer = true;
}