AirController icon indicating copy to clipboard operation
AirController copied to clipboard

Remove timeframe dependency

Open crashkonijn opened this issue 7 years ago • 0 comments

As Racso suggested to me:

you may be able to remove the need of having to Update every IInput. For the cooldown, instead of storing and reducing the cooldown, you can store the Time.unscaledTime when the button was pressed, and then check if Time.unscaledTime - buttonPressedTime > Input.BUTTON_COOLDOWN to see if the button is in cd or not As for making prevActive = active (such as in TouchPan), you can use Time.frameCount, which basically gives you the number of the current frame. When a button is pressed, instead of setting active = true, you can set activeInFrame = Time.frameCount. To check if the button is active, simply check if activeInFrame == Time.frameCount. To check if it was pressed last frame, activeInFrame == Time.frameCount-1. I may be missing something, but I think that would work, and would make your inputs Update-independent.

crashkonijn avatar Feb 24 '19 17:02 crashkonijn