- Home /
Frame dependant timer
Is there a way that I can make a timer that lasts for 1 frame? All of the timers that I can find are time based, as opposed to frame based.
Why would you need a 1 frame time? The Update loops is the frame loop. It should be as simple as this...
public int framesBeforeEvent;
private int frames;
private bool hasTriggered;
public void TriggeredEvent()
{
}
void Update()
{
if (!hasTriggered)
{
frames++;
if (frames >= framesBeforeEvent)
{
hasTriggered = true;
frames = 0;
TriggeredEvent());
}
}
}
https://answers.unity.com/questions/1482961/float-gets-tooo-many-additions.html
I want to try out Priyanka-Rajwanshi's answer.
This feels too spaghetti to get an actual answer. You're posting a question as a followup to another question without any context.
RobAnthem has already posted a solution to your problem: a way of ti$$anonymous$$g something based only on Frames passed. I think you should convert that to an answer / accept it and then open a new question (or watch / read tutorial).
Answer by Dolzen · Mar 23, 2018 at 04:43 PM
A timer that last for only 1 frame? Why would you want to do that? A timer cannot last for only 1 frame since that timer will have no time. It makes no sense.
If you want to check if something is happening in 1 frame use a bool instead.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Making a fill take exactly n seconds to complete 2 Answers
More timer from same class 1 Answer
CountDownTimer Help 1 Answer