I created the dynamic threshold while working on the Chimera Box game.
The problem that the dynamic threshold comes to solve:
When we have an input of continuous type, and we want to use it to determine a boolean condition.
In the game Chimera Box, this problem appeared in two cases, one of them is when we put the shot button on the right trigger on the controller, and the data we get is between 0 and 1. The first time we set the threshold at 0.5 as usual, we had situations where the players made a short press on the button and did not pass the threshold. So, we set the threshold to a lower number that would be easy to click, and the clicking travel distance would be optimal.
Now we have a new problem, there were players who kept pressing the key all the way, and when they wanted to cancel for a moment, did a half-unpressing, then pressed again. But this time when the threshold is on a low number, it didn't work for them.
Here, the dynamic threshold solves the problem.
In the beginning, a threshold distance is set. After that, the threshold is determined by the state we are in. If we are before clicking, the threshold will be the minimum position we have reached plus the threshold distance. If we are pressing, the threshold will be the maximum position we reached minus the threshold distance.
We set the threshold distance to 0.2. Now, before pressing, we have a value of 0 in the input. We set the threshold to 0.2. When the player passes 0.2, switch to pressed mode. Let's say he reached the press up to 0.8; now, the threshold to cancel the press will be 0.6. When it passes 0.6, we will return to the state waiting to be pressed, and so on.