A 2D top-down shooter prototype built with Unity. Move around a procedurally generated room, aim with the mouse, shoot enemies, collect coins, and step through the portal once the room is cleared.
Status: early prototype / learning project. Core gameplay loop works; progression, game-over flow and polish are still to come.
- Player control – WASD movement (physics-based), mouse aiming, left-click shooting
- Enemies
- Melee enemy that chases the player, with knockback and hit flash
- Ranged "mage" enemy that keeps its distance and fires projectiles
- Enemy spawner – spawns a fixed number of enemies per room and opens a portal when all are defeated
- Procedural room generation – wall border plus randomly placed obstacles
- Coins – dropped by melee enemies, magnetized toward the player, shown in the UI
- Health system – health bar with numeric text, screen shake on damage
- Camera – follow camera with map bounds, separate shake component
- Level loop – the portal reloads the scene to start a new room
- Unity 6000.3.29f1 (Unity 6) — see
ProjectSettings/ProjectVersion.txt - Universal Render Pipeline (2D)
- Git LFS (the repository's
.gitattributesdefines LFS rules)
Key packages (see Packages/manifest.json): Input System, Universal RP, 2D Tilemap, 2D Animation, uGUI / TextMesh Pro.
- Clone the repository (with Git LFS installed):
git lfs install git clone https://github.com/Chuan-dev086/UnityFirstGame.git
- Open Unity Hub → Add → select the cloned folder.
- Open the project with Unity
6000.3.29f1(Unity Hub will prompt to install it if missing). - Open
Assets/Scenes/SampleScene.unityand press Play.
| Input | Action |
|---|---|
W A S D |
Move |
| Mouse | Aim |
| Left mouse button | Shoot |
Input is currently read through Unity's legacy Input API (the project's Active Input Handling is set to Both).
- The room is generated (walls + obstacles) when the scene starts.
- The spawner creates enemies at a fixed interval around its position.
- Defeat all enemies to make the portal appear at the center of the room.
- Touch the portal to reload the scene and start the next room.
Assets/
├── Prefabs/ Bullet, EnemyBullet, Enemy, MageEnemy, Coin, Portal, WallPrefab, Obstacle
├── Scenes/ SampleScene (main game scene)
├── Scripts/
│ ├── Player/ PlayerMovement, PlayerHealth, PlayerStats
│ ├── Enemies/ EnemyAI (melee), EnemyRangedAI (mage), EnemySpawner
│ ├── Combat/ Bullet, EnemyBullet
│ └── Core/ LevelGenerator, CameraFollow, CameraShake, Coin, Portal
├── Settings/ URP and Input System settings
└── TextMesh Pro/ TextMesh Pro essentials and examples
Most gameplay values are exposed in the Inspector:
| Component | Notable settings |
|---|---|
PlayerMovement |
moveSpeed, bulletPrefab, gunPoint |
PlayerHealth |
maxHealth, health bar and text references |
EnemyAI |
moveSpeed, health, stopDistance, attackDamage, attackCooldown |
EnemyRangedAI |
moveSpeed, health, preferredDistance, retreatDistance, fireRate |
EnemySpawner |
enemyPrefab, spawnInterval, spawnRadius, enemiesToSpawn |
LevelGenerator |
roomWidth, roomHeight, obstacleCount |
CameraFollow |
target, useBounds, minBounds, maxBounds |
Tip: use an even value for roomWidth / roomHeight so the walls line up symmetrically.
- Player bullets and enemy bullets are destroyed by coins and the portal
- Health and coins reset when the portal reloads the scene (no cross-level persistence)
- No game-over screen or restart flow
- No shooting cooldown
- Spawner currently references only the ranged enemy prefab
- Camera bounds are not tuned to the room size
- Remove unused TextMesh Pro example assets to slim down the project
This is a personal learning project, but suggestions are welcome. Feel free to open an issue or a pull request. The repository uses feature branches and conventional-style commit messages (feat:, fix:, chore:, docs:).
This project is licensed under the MIT License.
Third-party assets such as TextMesh Pro and other Unity packages remain under their own licenses.