On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(+1)

It may not be the best way but what I use is a list of previous inputs I want to track, in my case it was vector2's up to 4 frames prior because I wanted to know directions, but you could do it with bools for input received etc:

List<bool> _prevInputs = new List<bool>();

and then inside each Update() (or method called inside Update):

 if (_prevInputs.Count > 4){ 
               _prevInputs.RemoveAt(0);
 }
_prevInputs.Add(input);

The same implementation can be used to check if we were grounded x frames ago to allow the player to coyote jump.

Your way may be better depending on what you want to achieve or there may be even better ways to achieve this that is more performant that what I've done, this is just simple and works for what I needed.

Deleted 3 years ago