Could someone please help me with a challenge I have? I am developing a Unity game where I need to tilt an iOS device to steer a ship as it flies in a straight line. The steering should be consistently accurate in any orientation, e.g. if the player holds the device directly in front of their face or if they are slouched over with the phone facing the ground etc. This is shown in the image below.
A summary of my needs are:
- Tilt the device to alter the on-screen ship's rotation (in Unity this is the object's y-axis since it is a top-down 3D game). This is why I say "tilt" (think Temple Run), panning around in space to change all axes is not necessary and needs to be prevented.
- I need to know how quickly the user is tilting their device to control the steering speed
- I need to know the current tilt angle at any instance
- I need to enforce a maximum tilt angle (e.g. tilting beyond +/- 45 degree has no further effect on the ship)
- I need smoothness and no jerkiness
Can someone with knowledge please advise me how to achieve this with the gyroscope in Unity? I have been experimenting with my phone using the Unity Remote app and playing around with the Input.gyro and Input.acceleration functions, but I cannot make sense of the angle data as the pitch and yaw of the device changes. As I say I need consistent behaviour. Some clear guidance would be appreciated tremendously!
I am really surprised by how few tutorials there are on this subject. I have done a lot of searching but there is very little advice online, which is strange since this seems like a very standard method of control.
