# 1. Space Invaders Project Setup and Playfield
Part of [[Space Invaders]]. Next: [[2. Space Invaders Player Cannon and Bullets]].
## 1.1 Create the project
1. In Unity Hub, create a project with Unity **6000.5** using the **Universal 2D** template (URP with the 2D Renderer). The template name wasn't re-checked in the 6000.5 Hub. Any 2D URP template works.
2. Confirm in **Window → Package Manager** that the **Input System** package is installed (1.20.1 ships in the 6000.5.8f1 templates). When asked whether to enable the new input backends, say yes.
3. Make these folders under `Assets/SpaceInvaders/`: `Art`, `Audio`, `Prefabs`, `Scripts`, `Scenes`, `UI`, `Tests`.
## 1.2 Pixel art that stays crisp
Draw (or download) small sprites: each invader type in two frames, the cannon, a bullet, a bunker cell, and the UFO. 8–16 px tall is authentic. For every sprite texture, in the Inspector:
| Setting | Value | Why |
|---|---|---|
| Texture Type | Sprite (2D and UI) | |
| Pixels Per Unit | **16** | One invader ≈ 0.5–0.75 units, which matches the spacing in part 3 |
| Filter Mode | **Point (no filter)** | No blurry edges |
| Compression | **None** | Compression smears 1-px detail |
Put all frames on one texture and use the Sprite Editor's **Slice** if you like. A sprite atlas is optional at this size.
## 1.3 Camera and playfield
The arcade is portrait. Use a 3:4 or 9:16 portrait Game view (add a custom resolution such as 640×960).
- **Main Camera:** Orthographic, Size **4.5** (the view is 9 units tall), position (0, 0, −10), background black.
- Add the URP **Pixel Perfect Camera** component to the camera. Set Assets Pixels Per Unit to 16, and pick a Reference Resolution that matches your art (for example 240×320). Turn on **Crop Frame** if you want letterboxing instead of stretching.
The scripts use these world-unit bounds (all serialized, so you can change them):
| Thing | Value |
|---|---|
| Rack left / right bounds | −3.4 / 3.4 |
| Rack start, top-left invader | (−2.5, 3.2) |
| Cannon y, cannon x range | −3.6, ±3.2 |
| Invasion line (game over) | y −2.6 |
| UFO lane | y 3.9 |
| Bullet despawn | \|y\| > 6 |
Add a thin green ground line sprite at y −3.9 for the look.
## 1.4 Physics layers and the collision matrix
Make these layers (**Edit → Project Settings → Tags and Layers**): `Player`, `PlayerShot`, `Invader`, `InvaderShot`, `Bunker`, `Ufo`.
Then in **Project Settings → Physics 2D → Layer Collision Matrix**, keep only these pairs:
| | Player | Invader | Bunker | Ufo |
|---|---|---|---|---|
| **PlayerShot** | – | ✔ | ✔ | ✔ |
| **InvaderShot** | ✔ | – | ✔ | – |
| **Invader** | – | – | ✔ (erases bunkers it marches through) | – |
Everything else off. The matrix is the first line of defence; the scripts still check `FromPlayer` so a mistake in the matrix fails safely. See [[3. Physics 2D Queries ContactFilter2D and Layers]].
## 1.5 Sorting
Use one Sorting Layer, `Gameplay`, and Order in Layer values of bunkers 0, invaders 1, bullets 2, UFO 3, cannon 4. The 2D Renderer sorts by these before depth.
## Exercises
1. Add a CRT look later with a full-screen Renderer Feature ([[Post-Processing]]). For now, keep the frame clean so you can read hitboxes.
2. Set the Game view to "Low Resolution Aspect Ratios" off, and check that the Pixel Perfect Camera shows no shimmering when the cannon moves.