- Home /
How to create a frame indipendent timer
Hi everyone,
I'm having some issues in finding a way to implement a trap that springs out at a set amount of time with constant results.
Basically, I want to make the trap hit the player if he triggers it by moving under a certain velocity, but miss him if the player triggers it over the set velocity. I don't want to use an if statement.
I tried using a simple coroutine with a "waitforseconds" but the rate of success is inconsistent, and the timer is frame-dependent, giving me hard times with low fps. The value I'm using in the coroutine is between 0.15f - 0.25f.
I've also tried with a while loop, a for loop and so on (with or without Time.deltaTime and fixedDeltaTime), but without any decent result. I've also tried using Smoothdamp, Lepr and so on, but they do not work as intended.
So, does anyone have any tips on how to address this problem? How can I have an FPS independent timer with decimal values that behaves in a consistent way?
Thanks in advance for any answer.
Your answer
Follow this Question
Related Questions
How would I make a timer frame independent? 1 Answer
Using Time efficiently regardless of current frame rate. 0 Answers
Making a fill take exactly n seconds to complete 2 Answers
Timer "overshooting" very small interval check 1 Answer
I cant get this timer to start when this bool turns true? 1 Answer