I am trying to use the iPhones gyro to implement a shake feature. I particularly care about the direction of the shake.
What I’m finding is “Input.acceleration” doesn’t return a acceleration at all but an value corresponding to the tilt of the device.
If you leave the device still but not level , you always get a reading. Hence, if I prop the device up you will find that either Input.acceleration.x or Input.acceleration.y comes back a consistent large value.
A cut down example of the code looks something like this:
var dir : Vector3 = Vector3.zero;
dir.x = -Input.acceleration.y;
dir.z = Input.acceleration.x;
dir *= 30;
myObject.rigidbody.velocity += dir;
This is fine if I want a tilting type of control (above works quite well for that) but I’m after acceleration.
Acceleration events I dont think will help me either.
Ideas?