Accessing the accelerometer

…Mobile devices often have other input sensors, besides the touch screen.…Most mobile devices nowadays come with accelerometers.…The accelerometer measures the forces acting on the device.…It returns a three dimensional vector, which is…the force along each of the three axes.…The x axis is along the shorter side of the device.…The y axis is along the longer side.…And the z axis is coming out of the screen.…So if you are holding the device in portrait mode, the positive…x axis would be going out the right side of the device,…the positive y axis would be going out the top of the…device and the positive z axis would coming out of the screen.…

We're going to add accelerometer support, so the user can move…their ship by rotating their device rather than using the pan gesture.…Since the accelerometer is still a form of user input, we're…going to add the code to the user input handler class.…The first thing we're going to do is create…another event that will send the current acceleration every frame.…We'll call the event onAccelerometerChanged.…

Resume Transcript Auto-Scroll

Author

Released

7/23/2014

Developing mobile games in Unity takes a different skill set than building desktop or console games. You have to take screen resolution, special inputs like touches and accelerometer data, and performance into account. This course shows you how to meet these challenges and optimize your game development workflow specifically for mobile. Author Kelley Hecker explains how to set up the development environment to deploy to iOS and Android devices, access inputs from the device, and design user interfaces to work with multiple resolutions. Plus, learn how to debug a game while it's running on a device, and optimize your games to get faster, smoother performance.