- Home /
reaction game: measure time of touch exactly?
Imagine a simple reaction game. on iOS touch device.
I set a texture to change color signifying it's time for the player to respond.
How do I exactly measure the time of the touch from the time of the display of the "go touch the screen" signal regardless of the frame rate of the app?
Answer by Jessy · Mar 17, 2011 at 01:34 PM
You can only get input in a frame. There is no exact timing(*); the lower your framerate, the less accurate timing is. If you're not taking pausing into considering, you can just store the Time.time when you like, and then subtract than from a later Time.time to get the delta. If pausing is coming into play, then you probably just want to add Time.deltaTime, every frame, to a variable that starts at zero.
(*) FixedUpdate is an option, but it should only be used when your input is directly related to physics. If you put too much in FixedUpdate, or make fixedDeltaTime too low, then the concept of FixedUpdate will become meaningless because there won't be enough horsepower to keep the higher framerate up for anything.
Just make sure your framerate is good. People don't sense time very meaningfully at the 30-60 fps level.
so to within a 60th of a second is the most accurate a "reaction test" game could be using Unity and iOS?
No, you can run it faster, but the screen tops out at 60 fps. Do you really, seriously think that greater precision is going to help your game? 16.7 ms is less than you're going to find almost every musician/producer using, for audio buffer delay. You can't even hear that difference as a separate sound; it just makes a comb filter. http://en.wikipedia.org/wiki/Flanger
it's important for the scoring system that it be be as responsive as possible in my game concept. however, imagine a reaction tester. $$anonymous$$ost folks are between .25 and .4 seconds. 1/60th of sec accuracy means only 9 variations in ti$$anonymous$$g possible in that swamped range.
And when folks start getting good, bringing it down to .2 to .25 there's only 3 different ti$$anonymous$$gs. ... and from what you're saying, the whole game must be sped up to get better/more accurate ti$$anonymous$$gs? $$anonymous$$eaning animations, sounds etc must be $$anonymous$$imized to get the performance?
Just for anyone reading this, "so to within a 60th of a second is the most accurate a "reaction test" game could be using Unity and iOS?" It's totally inconceivable, on a touch screen device, to have any app at all that has input where time frames smaller than that are relevant.
Just TBC in games that "display" a very accurate, like two decimals, "reaction speed" - you simply randomly choose a value for the last digit or so. Every time you've ever played a game and you've seen that, that's what you're seeing.