How do i detect how fast a user clicks a mouse or a button .
lets say i have a variable Var_Speed and i want the variable to keep increasing as the user click the mouse multiple times and if the user stop clicking, the variable slowly decrease until it reaches zero
also if the click rate changes the variable also change to match the rate of the click.
any idea?
You can get the unit rate in this case by dividing the count of clicks/taps by a period of time. Then it would be taps / time rate.
Now how do you decide if to increase or decrease? Keep book about the previous unit rate, and compare to it to the latest. If it’s lower, then reduce the speed, if it’s faster, then increase the speed. And to avoid change being sudden, you could interpolate the value by using Math.Lerp or something else to transition from old speed to the new speed. And then wait for the next check period again… and do adjustment again. And if there’s no clicks at all, you could use some appropriate decay value, that is reduced every update cycle you reduce the value. Anyway, there’s many ways you can do this.