at 24fps it's 41.66 milliseconds between frames. Can I get more accurate information about the timings of the players tap/touches of the screen than that, or the reports on touch time locked to the fps?
I want to know the EXACT moment in time between touches. Or as exact as the iPhone clock enables whilst running a game.
Consider 24fps an arbitrary frame rate. It could be 30fps, 60fps or any other rate the iPhone funs at. The point of interest is exact measurement of tap times independent of frame rate. Possible how?
Answer by Eric5h5
Mar 12, 2011 at 09:57 AM
The iPhone screen doesn't do 24 fps, it's vsynced always, so you get 60 fps or 30 fps (or 15 I suppose). In any case, as the docs say, "You can retrieve the status of each finger touching the screen during the last frame by accessing the Input.touches property array."
You forgot 20 fps. Also, the profiler tells me I can get ~40ms frame times, too, suggesting 25 is possible. ???
I believe deltaTime measures in seconds as the rest of the framework does so. So a value of 0.1 delta time means 0.1 seconds since last change.
Answer by Statement
Mar 16, 2011 at 02:12 PM
This might be a slight far shot since I have absolutely zero experience with iPhone and developing for it.
I just thought I'd mention that if (and only if) there is a thread safe way of polling the touch data, either via Unity3D or via some other library (if that is supported on iPhone), and if (and only if) you can create threads on iPhone, then;
Create a new thread that samples the data at your fixed intervals and produce a message queue with the samples that you can use in Update via a synchronized Queue. This will in theory allow you to sample input at a higher frequency than your game is updating. You'd typically have to dequeue all of the results to get to the data you're after (maybe you want to smooth it over time or maybe you just want to check for rapid, fine granular movements).
See Queue.Synchronized, Threading, and Threading Tutorial.
This will only work if you can create threads and access input directly. Otherwise this answer is moot and offer no value.
so the answer is, "for exact measurements of tap timings use Objective-C?
No, not really. The answer is "if unity iPhone support libs and threads, then you can make a new thread and call the lib that can provide such polling". I don't know enough iPhone development to know fully what is supported or not, but in an ideal world you wouldn't have to touch Objective-C for this task. The threading and synchronized queue are all in .net/mono. How to actually sample the values I don't know. If you can get a library that does this, then use that in the thread.
Reading the licenses it seems you can be able to do this. http://unity3d.com/unity/licenses.html See plugins. http://unity3d.com/support/documentation/Manual/Plugins.html
Answer by Statement
Mar 16, 2011 at 02:28 PM
I want to know the EXACT moment in time between touches.
The point of interest is exact measurement of tap times independent of frame rate. Possible how?
From the input docs:
The iPhone/iPad screen is able to distinguish quick finger taps by the user. This counter will let you know how many times the user has tapped the screen without moving a finger to the sides.
Android devices do not count number of taps, this field is always 1
See Touch.tapCount. You can get Touches from Input.touches.
I don't know if this solves your problem or not, it apparently it will count the taps for you. If this is frame rate independent or not, I can't tell. If it is frame rate independent it probably won't offer you information about how long it took between each tap as it is only a value describing the number of taps. There exist also a deltaTime variable, but I don't know if you get a touch sample for every little tap. If you do, you can measure the distance in time between taps with this.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
1 Person is following this question.
Mobile input problem for first-person shooter
TWO GUI texture that doesn't work together
Counting iphone FPS
Mobile keyboard questions
3D Touch (Apple) implementation