How to Use Unity: A Beginner’s Guide to 2D, 3D, C#, and Mobile
Key Takeaways
- Unity is free for beginners and supports both 2D and 3D game development, with over 50% of mobile games built using it (per Unity’s 2023 report).
- You’ll need basic C# knowledge, but Unity’s visual tools let you prototype without writing code initially.
- Mobile deployment requires specific settings (e.g., screen resolution, touch controls), which I’ll cover step-by-step.
- Focus on small projects first—like a 2D platformer or a simple 3D cube game—to avoid overwhelm.
What Is Unity and Why Use It?
Unity is a cross-platform game engine that powers everything from *Hollow Knight* (2D) to *Pokémon GO* (AR mobile). It uses C# for scripting and offers a visual editor for designing levels, characters, and physics. As of 2024, over 1.5 million developers use Unity monthly, and it supports 25+ platforms, including iOS, Android, Windows, and consoles.
For beginners, Unity’s free Personal plan gives you all core features until your revenue hits $200,000 per year. That means you can start learning without paying a dime.
Step 1: Install Unity and Create Your First Project
1. Download Unity Hub from unity.com.
2. Install a Unity version (I recommend 2022.3 LTS for stability).
3. Create a new project: Choose “2D Core” for 2D games or “3D Core” for 3D. Name it “MyFirstGame.”
4. Explore the interface: You’ll see the Scene view (where you build), Game view (preview), Hierarchy (list of objects), Inspector (properties), and Project panel (assets).
Pro tip: Start with 2D if you’re brand new—it’s less complex. My first Unity project was a 2D space shooter, and it took me about 3 hours to get a moving ship.
Step 2: Build a Simple 2D Game (Without Code First)
Unity lets you drag-and-drop sprites and add physics. Here’s a 5-minute exercise:
- Import a sprite: Drag a PNG (e.g., a square) from your computer into the Project panel.
- Add it to the scene: Drag the sprite from Project to the Scene view.
- Make it fall: In the Inspector, click “Add Component” → “Rigidbody 2D.” Now it obeys gravity. Press Play to see it fall.
- Add a collider: Add “Box Collider 2D” so it can collide with other objects.
You just made a physical object without writing a single line of code. This is Unity’s superpower for prototyping.
Step 3: Scripting with C# (The Core of Game Logic)
Scripts control behaviors like movement, scoring, and enemy AI. Here’s a basic movement script for a 2D player:
```csharp
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float speed = 5f;
void Update()
{
float moveX = Input.GetAxis("Horizontal");
Vector2 movement = new Vector2(moveX, 0);
transform.Translate(movement * speed * Time.deltaTime);
}
}
```
How to use it:
1. Right-click in Project panel → Create → C# Script. Name it “PlayerMovement.”
2. Double-click to open it in your code editor (Visual Studio works best with Unity).
3. Replace the default code with the above.
4. Attach the script to your player object by dragging it onto the object in the Hierarchy.
5. Press Play. Use A/D or arrow keys to move left/right.
Explanation: `Input.GetAxis("Horizontal")` returns -1 (left), 0, or 1 (right) based on keyboard input. `Time.deltaTime` makes movement frame-rate independent—critical for consistent speed on different devices.
Comparison: 2D vs 3D Scripting
| Aspect | 2D | 3D |
| -------- | ---- | ---- |
| Coordinates | x, y (ignores z) | x, y, z |
| Physics | Rigidbody2D, BoxCollider2D | Rigidbody, BoxCollider |
| Camera | Orthographic (no perspective) | Perspective (depth) |
| Common Use | Platformers, puzzles, RPGs | Shooters, open worlds, sims |
My opinion: Start with 2D scripting—it’s easier to debug because you only worry about two axes. Once you’re comfortable, switch to 3D.
Step 4: Mobile Deployment (Android & iOS)
To deploy to mobile, you’ll need extra setup:
1. Switch platform: File → Build Settings → Select Android or iOS → Switch Platform.
2. Install modules: Unity Hub → Add modules for Android (SDK, NDK, JDK) or iOS (requires Mac and Xcode).
3. Adjust for mobile:
- Input: Replace keyboard controls with touch or tilt. Unity’s `Input.touches` array handles multi-touch.
- Resolution: Set the Game view to a mobile aspect ratio (e.g., 9:16 for portrait games).
- Performance: Use mobile-friendly assets (e.g., low-poly models, compressed textures).
4. Build and test: For Android, generate an APK file and install on your phone. For iOS, build to Xcode, then deploy to your iPhone.
Real-world tip: My first mobile build took 2 hours because I forgot to set the minimum API level for Android. Always check “Player Settings” → “Other Settings” → “Target API Level” to match your device.
Common Beginner Mistakes (and How to Avoid Them)
- Forgetting to save scenes: Unity doesn’t autosave. Press Ctrl+S (Cmd+S on Mac) every time you add an object.
- Using too many assets: A 2D game can run fine with 50 sprites, but 500 will slow your phone. Optimize early.
- Ignoring the console: Errors in red appear in the Console panel. Read them—they tell you exactly what broke.
FAQ
Q: Do I need to know C# before starting Unity?A: No, but it helps. You can build simple games with visual scripting (e.g., Bolt add-on) or by copying basic scripts. However, learning C# basics (variables, if-statements, loops) will save you time after the first week.
Q: Can I publish my Unity game to the App Store for free?
A: Unity itself is free, but Apple charges $99/year for a developer account, and Google charges a one-time $25 fee. You’ll also need to pay for assets if you don’t make your own.
Q: How long does it take to make a simple mobile game?
A: A basic 2D game like Flappy Bird clone takes about 2-3 days for a beginner. A polished 3D game with menus and levels might take 2-3 months. Start small—I made my first complete game in 4 days.
Next Steps
Now you know how to install Unity, create a 2D scene, write a C# script, and prepare for mobile. Your next project: make a ball roll in 3D using `AddForce()`. Practice by adding a score counter and a restart button. The official Unity Learn site has free tutorials that walk you through this in 20 minutes.