Hi,
I am trying out Input.gyro and Input.acceleration for detecting if a device, phone or tablet, is being tilted left, right, back, or front, by the user.
I tried Input.acceleration, and it seemed to work, but after reading up on it, it did not seem that it was designed for that. It seemed like Input.gyro was what should be used for this. Particularly because acceleration did not really detect how many degrees the phone is tilted.
I set up a base-line/tare functionality for the user to say, “the current tilt is zero, and should represent a tilt that tells gameobjects not to move in any direction”.
The objects move using Input.acceleration, but I want to be able to tell the objects to use an in-game ability, also called acceleration. I don’t want the object to gradually accelerate to this speed. I want it able to be activated instantly if the user tilts their device far enough in one direction. If they tilt less than this threshold, the object simply moves and accelerates at its base speed/acceleration.
The problem is, even though, from my reading, Input.gyro should be the correct API, it simply doesn’t work at all, at the most basic level. I even made sure gyro.enabled is set to true. When I set it to true, the game objects move, but instantly towards the upper right corner of my device (forced landscape view). And the direction they move in cannot be affected by tilting the device in various ways.
I tried gyro.attitude, rotateRateUnbiased, and userAcceleration. Nothing seems to work. What mistakes am I making here?
My intent is fairly simple, as described above. But in addition, I would also like to be able to shake the phone in a z direction in my hand, to tell the objects to jump. By this, I mean, instead of shaking the phone side to side, I would move my hand down quickly and shortly in the direction of earth gravity, before immediately bring the phone back up (all in a shaking motion).
Thank you for any help!