- Home /
OnTriggerStay for multiple seconds
Hey guys! I have a character who I want to die if he is in a certain area for too long (4 seconds). If he jumps out of the area (let's say its a fire) I want the timer to reset. That would be easy, but my character can also turn invisible, in which case he also shouldn't get killed by the fire and the timer should reset (because you can't be burned if youre invisible.
I tried yield WaitforSeconds (4) but that didn't work because you could hop in the fire for .1 second, turn invisible and then your invisibility could run out after 3 seconds and you change back and instantly die.
If anyone has an idea how to do this, Id greatly appreciate it!
Answer by zero_null · Dec 15, 2017 at 08:32 AM
You are not doing it correctly. You shouldn't be waiting in the OnTriggerStay. If you want you should increase time in the update loop and add a check in OnTrigerStay to know if you are exactly in the Fire and it's been more than 4 seconds so that you can kill the player.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
C# Make something happen for X amount of Seconds. 2 Answers
Pause game while GUI instructions displayed? 1 Answer
Fade in AudioLister over time #c 1 Answer