Controlling with tilt

Modern mobile devices possess a broad variety of internal sensors for detecting and providing information about the surronding world. Though you may not have thought of them in such a way, you are certainly most familiar with the microphone and speaker that are required for making calls. There is a Wi-Fi receiver for connecting to the Internet and a camera for taking pictures. Your device almost certainly has a magnetometer to work with your GPS to provide directions.

The sensor we are interested in right now is the gyroscope. This sensor detects local rotation of the device. In general, it is used to determine the orientation of the device. We are going to use it to steer our ship. When the user tilts their device left and ...

Get Unity Android Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.