How to Use Unity: A Beginner's Guide to 2D, 3D, Scripting, and Mobile Deployment
Key Takeaways
- Start with Unity Hub and the Personal plan (free, no royalties) – you can publish games earning up to $100k/year without paying a dime.
- For 2D projects, use the built-in Sprite Shape and Tilemap tools; they cut level design time by 40% compared to placing sprites manually.
- C# scripts are attached to GameObjects – think of them as behaviors. The `Start()` and `Update()` methods run automatically.
- Mobile deployment requires switching build settings and adjusting touch inputs; expect a 2–3 day learning curve for your first APK or IPA.
---
1. Setting Up Unity for the First Time
Download Unity Hub from unity.com. It’s a launcher that manages versions and projects. I recommend Unity 2022 LTS (Long Term Support) – it’s stable and has the best documentation. Avoid the latest beta unless you like debugging.
During installation, check the boxes for Android Build Support, iOS Build Support, and Windows/Mac Build Support. This saves hours later. If you skip them, you’ll need to re-run the installer.
Create a new project: choose 2D Core or 3D Core template. The 2D template sets the camera to orthographic (no perspective) and imports the Sprite package automatically.
---
2. Navigating the Editor (No Panic)
When the project opens, you see five main panels:
- Scene View: where you build the world (drag objects, rotate, scale).
- Game View: shows what the player sees (press Play to test).
- Hierarchy: lists every object in the current scene.
- Inspector: properties of the selected object (position, scripts, materials).
- Project Window: your asset files (sprites, scripts, audio).
Pro tip: If a panel disappears, go to `Window > Layouts > Default`. Resets everything.
---
3. Creating a 2D Scene (Example: Platformer Ground)
1. In the Hierarchy, right-click > 2D Object > Sprite.
2. In the Inspector, click the circle next to Sprite and choose a square (built-in).
3. In the Project window, create a folder called `Sprites` and drag your own image there.
4. To add a ground tile, use Tilemap: `Window > 2D > Tile Palette`. Create a palette, assign sprites, then paint in Scene view.
Real numbers: A single Tilemap can hold 65,536 tiles – more than enough for a small platformer. I once built a 50-level game with just 3 tilemaps.
---
4. 3D Basics: Lighting and Simple Objects
Switch to 3D by changing the Scene view to Shaded mode (top-left dropdown).
- Add a cube: `GameObject > 3D Object > Cube`.
- Add a point light: `GameObject > Light > Point Light`. Set intensity to 2 for a warm glow.
- To make objects respond to gravity, add a Rigidbody component in the Inspector (click Add Component > Physics > Rigidbody).
Comparison: 2D vs 3D Workflow
| Aspect | 2D | 3D |
| -------- | ---- | ---- |
| Camera | Orthographic (no depth) | Perspective (depth) |
| Main component | Sprite Renderer | Mesh Renderer + Collider |
| Physics | Rigidbody 2D, Collider 2D | Rigidbody, Collider |
| Lighting | Usually baked sprites | Real-time or baked lights |
| Performance | Lighter, runs on old phones | Heavier, needs GPU |
---
5. C# Scripting: Your First “Hello Movement”
Scripts are text files that tell GameObjects what to do. Let’s make a cube move with arrow keys.
1. In Project window, right-click > Create > C# Script. Name it `PlayerMovement`.
2. Double-click to open Visual Studio (or your code editor).
3. Replace the default code with:
```csharp
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float speed = 5f;
void Update()
{
float moveX = Input.GetAxis("Horizontal");
float moveY = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveX, moveY, 0) * speed * Time.deltaTime;
transform.Translate(movement);
}
}
```
4. Save the script. Drag it onto your Cube in the Hierarchy. Press Play – the cube moves with arrow keys.
Key lesson: `Time.deltaTime` makes movement frame-rate independent. Without it, the cube moves faster on high-FPS monitors.
---
6. Mobile Deployment: From Editor to Phone
First, set your project for mobile:
- Go to `File > Build Settings`.
- Select Android or iOS and click Switch Platform.
- For Android: Install the Android SDK (Unity prompts you). Set `Player Settings > Package Name` to something unique, like `com.yourcompany.gamename`.
- For iOS: You need a Mac with Xcode installed.
Touch input example (simple left/right):
```csharp
if (Input.touchCount > 0)
{
Touch touch = Input.GetTouch(0);
if (touch.position.x < Screen.width / 2)
// Move left
else
// Move right
}
```
Build and run: connect your phone via USB, enable Developer Options (Android) or trust the developer (iOS). The build time for a small game is about 1–2 minutes.
---
7. Common Mistakes and How to Avoid Them
- Forgetting to save scenes: Unity crashes happen. Hit Ctrl+S (Cmd+S) every 10 minutes.
- Too many GameObjects: Each one costs draw calls. Use object pooling for bullets or enemies.
- Hardcoding values: Always expose variables as `public` in scripts so you can tweak them in the Inspector without recompiling.
---
FAQ
Q: Do I need to know C# before starting Unity?
A: No, but basic programming concepts help. Start with small scripts like the one above. Unity’s documentation and YouTube tutorials (e.g., Brackeys) are your friends. Expect to Google every 20 minutes for the first month.
Q: Can I publish a mobile game without spending money?
A: Yes. Unity Personal is free. To publish on Google Play, you pay a one-time $25 fee. For Apple App Store, it’s $99/year. Asset store purchases optional.
Q: Why is my 3D game lagging on mobile?
A: Likely too many polygons or real-time lights. Use the Profiler (Window > Analysis > Profiler) to find bottlenecks. Reduce polygon count (under 50k for mobile) and bake lighting instead of real-time.