hello i have a game done with unity on pc/mac standalone how can i manage to convert the mouse/keyboard input into touch based sens and add an accelerometer to the game… all i want is to play it on android smart phone i have unity pro trial for now. the game is an fps shooter game ty
The people at Unity have done a lot to make it easy to convert your PC game to a mobile game. But, obviously it can’t convert input by default. So, the simplest way to replicate a two joystick FPS controller is to do the following:
- Create two controller prefabs. Unity includes these in the mobile standard assists.
- Edit your movement code to respond to joystick.input instead of keystrokes and mouse movements.
- There is a standard 2-joystick controller included in the mobile standard assets. If you want a real easy solution, I might recommend that rig and just adding your scripts to it.
Responding to finger drags is as easy as responding to touch.deltaPosition when you move.
And then there’s the accelerometer. This depends on how the device is oriented, but basically taking the atan
of the various different accelerometer positions with respect to the other 2 will tell you the current angle of the device.
And finally don’t forget that you can use conditional compilation to make cross-platform development easier:
#if UNITY_IPHONE
///Do stuff
#endif
hey thx for the info i did it as u mentioned still have some compiler error trying to fix but i guess i solved the axis issue and input issue and working on compressing the graphic quality to work on my smartphone… ill keep this thread updated tx again