- Home /
Precise gamepad timing
Hello
I'm working on an application where I need very precise timing for gamepad inputs. Ideally, down to the millisecond, with multiple presses of the same button being possible within a few milliseconds. (The controller isn't actually a gamepad; it just uses the guts from a gamepad, with the buttons connected to other sensors.)
Unfortunately, it seems that gamepad button pushes are linked to Update, not Fixed Update. It's not possible to change the Fixed Timestep and use FixedUpdate because the results don't change until Update runs again. (E.g.: If the app is running at 60 FPS, Update is called every 16.667ms. If I set FixedUpdate to run every 2ms, ButtonDown will return true 8 times or so times in a row when I want it to return true only once.)
I'm currently working on Mac OS X (10.9.2/Mavericks) and don't currently have a way to confirm this on other platforms.
Is there a way to achieve the desired precision inside of Unity? If not, are there any existing libraries that do provide this functionality?
Thank you.
Can you not place your input checks in FixedUpdate ins$$anonymous$$d?
For a similar problem with $$anonymous$$ecanim I simply changed a flag then record state to LastFrame variable. If-check for Press true this frame && false last frame, so repeat Press = true has no effect.
I did it this way so I could inject changes to Press (attack in my case) from other scripts with less problems and stick in an easy attack-on var with a timed off.
If you're using Unity Pro you could always build your own plugin and go straight to the OS with platform specific code.