Ok, here’s my problem.
I’m building a custom input management class to substitute/integrate unity’s built-in Input Manager.
I’m stuck at a point when i’m trying to mimick unity’s GetButtonDown method, that returns true in the only frame in which GetButton becomes true.
I tried to do something like this (C#):
[...]
bool last = false;
bool TestFunction(bool truth)
{
bool result = !last truth;
last = truth;
return result;
}
[...]
But this has some disadvantages:
- It only works if you call it in a Update method
- It requires constant input polling
- If more than one call per frame is made the result gets messed up.
Do you have any better ideas for implementing this?