Reputation: 9646
I'm currently building a game, and for one of the controls I plan on using the gyroscope. As one of the conditions will be holding the phone steady for some period of time, can anyone think of any ingenious ways to detect whether someone has simply placed their phone on a flat surface and left it?
I thought about using the accelerometer to detect if it's quickly put down, but then if they're travelling and playing (it's a casual game) this will give wrong readings and potentially punish people incorrectly. I also thought about the proximity sensor, but this would require the phone to be placed faced down on the table in order to detect if they're cheating so obviously not a solution either. Either that or they'd need to be hunched over the device.
Can anyone think of any good solutions, or am I just barking up the wrong tree with an idea here?
The only other potential solution I can think of is that there's a small circle within a larger circle and they have to use the gyroscope to keep it as close to the middle as possible. I could random create "wobbles" every now and then (much like in the old hitman games how the sniper rifle would never actually be 100% still to simulate natural breathing wobble etc.)
Upvotes: 1
Views: 165
Reputation: 124997
can anyone think of any ingenious ways to detect whether someone has simply placed their phone on a flat surface and left it?
Nobody can stay completely still for any length of time. Photographers try their best in order to shoot at slow shutter speeds, but just your breathing and heartbeat create tiny movements.
Wire up a simple test project that uses Core Motion to look at accelerometer data when you're holding the device as still as you possibly can and also when it's sitting on a table. iOS apps often use a low-pass filter to filter out those tiny random motions and look only at the big, slow, intentional movements; you might want to do the opposite and look at small, high-frequency changes that will be the difference between a person trying to stay steady and a table that really is motionless.
Upvotes: 1