I knocked up a quick demo to show how you might create a Unity game, which uses either keyboard input, or the accelerometer of a mobile device, without having to change any code, include any third party libraries, or use conditional compilation.
The pattern looks like this – if touch input is available, it’s probably a mobile device, so use the accelerometer to apply force to your player. Otherwise, just use the standard input axes (which will take arrow keys, or gamepad input , if available):
You must be logged in to post a comment.