CHAPTER 14
Beginner
Mobile Game Development Basics
Updated: May 16, 2026
30 min read
# CHAPTER 14
Mobile Game Development Basics
1. Introduction
The mobile gaming market is the largest sector in the video game industry. A simple hyper-casual game released on iOS or Android can reach millions of players worldwide. However, mobile devices do not have keyboards or mice; they rely entirely on multi-touch glass screens. Furthermore, a mobile phone has a fraction of the processing power of a gaming PC, requiring strict optimization. In this chapter, we will master Mobile Game Development Basics. We will learn how to read raw touch inputs, implement virtual on-screen joysticks, configure responsive UI, and prepare our project for an Android build.2. Learning Objectives
By the end of this chapter, you will be able to:- Switch a Unity project's build target from PC to Android/iOS.
-
Read multi-touch screen inputs using
Input.touches.
- Implement virtual on-screen UI joysticks and buttons.
- Optimize graphics settings for low-end mobile hardware.
- Build an Android APK file for device testing.
3. Switching the Build Platform
By default, Unity assumes you are making a Windows/Mac PC game. To unlock mobile features, you must switch the engine's target architecture.- 1. Go to File -> Build Settings.
- 2. Under "Platform", select Android (or iOS).
- 3. Click the Switch Platform button. Unity will take a few minutes to re-compress all your audio and textures into mobile-friendly formats.
4. Reading Touch Input (The Raw Way)
Instead ofInput.GetKeyDown, mobile phones track multiple fingers touching the screen simultaneously using an Array called Input.touches.
csharp
5. On-Screen UI Joysticks
Writing raw touch math to simulate a thumbstick is incredibly tedious. Unity provides a free, pre-built package for this!- 1. Open the Package Manager (Window -> Package Manager).
- 2. Install the Device Simulator or the Standard Assets (CrossPlatformInput) (depending on your Unity version).
- 3. Alternatively, search the Asset Store for "Free Mobile Joystick".
- 4. You simply drag the UI Joystick Prefab onto your Canvas.
-
5.
In your C# code, instead of
Input.GetAxis("Horizontal"), you change it toFixedJoystick.Horizontal. The transition takes 5 seconds and perfectly maps your PC movement code to a touch screen!
6. Mobile Optimization (Crucial Step)
A beautiful PC game will melt a phone's battery and run at 10 FPS. You must optimize:- Shadows: Real-time shadows are incredibly expensive on mobile. Go to Edit -> Project Settings -> Quality, and change Shadows to Hard Shadows Only, or disable them completely and use "Baked" (pre-painted) lighting.
- Poly Count: A PC character can have 50,000 polygons. A mobile character should be kept under 10,000.
- Post-Processing: Avoid heavy effects like Depth of Field or Ambient Occlusion on mobile.
7. Building an Android APK
To play the game on your physical Android phone:- 1. Ensure your phone is plugged in via USB and "Developer Options / USB Debugging" is enabled on the device.
- 2. In Unity, go to Edit -> Project Settings -> Player.
- 3. Under the Android tab, set the Company Name and Product Name.
- 4. Set the Minimum API Level (e.g., Android 8.0).
- 5. Go to File -> Build Settings.
-
6.
Click Build and Run. Unity will compile the C# code into a
.apkfile, push it through the USB cable, and instantly launch the game on your phone!
8. Visual Learning: Touch Phases
txt
9. Best Practices
- Device Simulator: You don't have to build an APK every time you want to test mobile UI. Unity has a built-in Device Simulator window (accessible next to the Game tab). It overlays a virtual iPhone or Samsung bezel over your game, allowing you to perfectly test UI Safe Areas (preventing UI from being hidden under the camera notch) right in the editor.
10. Common Mistakes
-
Assuming Mouse = Touch: In the Unity Editor, clicking the mouse emulates a touch, making it easy to test. However, relying on
Input.GetMouseButtonDown(0)in your final mobile build can cause weird glitches on multi-touch devices. Always switch to trueInput.toucheslogic before publishing a mobile game.
11. Mini Project: Convert to Mobile Controls
Objective: Replace PC keyboard movement with mobile UI buttons.- 1. Create a Canvas with two Buttons anchored to the bottom corners. Label them "Left" and "Right".
-
2.
Add an
EventTriggercomponent to each button. This allows us to detect when the button is *held down*, not just clicked once.
-
3.
Create a
MobileControllerscript:
csharp
- 4. Map the UI Event Triggers to these functions. You can now steer your character using your thumbs on the screen!
12. Practice Exercises
-
1.
What menu option must you select to reconfigure Unity's backend from compiling
.exefiles to compiling.apkfiles?
-
2.
If you want to run code only on the exact frame a player's finger lifts off the glass, which
TouchPhaseshould you check for?
13. MCQs with Answers
Question 1
When developing a game for low-end mobile devices, which graphics feature is considered highly expensive and should often be heavily restricted or baked?
Question 2
How does Unity represent the data of multiple fingers touching the screen simultaneously?
14. Interview Questions
-
Q: Explain the lifecycle of a mobile touch input via the
TouchPhaseenum. How doBegan,Moved, andEndedcorrelate to standard mouse clicks?
- Q: A PC game port is running at 15 FPS on a modern smartphone. Detail three specific rendering optimizations you would perform in the Unity Editor to drastically improve performance.
- Q: Describe the workflow for testing mobile UI responsiveness in the Unity Editor without having to build to a physical device every 5 minutes.
15. FAQs
Q: Can I build an iOS game using a Windows PC? A: No. While you can *develop* the game on Windows, Apple has a strict walled garden. To actually compile the final.ipa file to put on an iPhone or the App Store, you MUST export the project to an Apple Mac computer running Xcode.
16. Summary
In Chapter 14, we transitioned into the mobile market. We learned how to switch our build architecture to Android and use the Device Simulator to test screen resolutions. We bypassed traditional keyboards, implementing raw multi-touch tracking via theInput.touches array and utilizing virtual on-screen joysticks. Finally, we learned critical rendering optimizations required to keep our games running smoothly on battery-powered hardware, and outlined the pipeline for compiling a playable .apk.