Skip to content

About

A 2D top-down survival shooter built with Unity and C#. Features player movement, mouse aiming, shooting mechanics, melee and ranged enemies, health management, coin collection, procedural room generation, and wave-based enemy encounters.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

29 Commits

Folders and files

Repository files navigation

UnityFirstGame

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.

Features

  • 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

Requirements

  • Unity 6000.3.29f1 (Unity 6) — see ProjectSettings/ProjectVersion.txt
  • Universal Render Pipeline (2D)
  • Git LFS (the repository's .gitattributes defines LFS rules)

Key packages (see Packages/manifest.json): Input System, Universal RP, 2D Tilemap, 2D Animation, uGUI / TextMesh Pro.

Getting Started

  1. Clone the repository (with Git LFS installed):
    git lfs install
    git clone https://github.com/Chuan-dev086/UnityFirstGame.git
  2. Open Unity Hub → Add → select the cloned folder.
  3. Open the project with Unity 6000.3.29f1 (Unity Hub will prompt to install it if missing).
  4. Open Assets/Scenes/SampleScene.unity and press Play.

Controls

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).

Gameplay Loop

  1. The room is generated (walls + obstacles) when the scene starts.
  2. The spawner creates enemies at a fixed interval around its position.
  3. Defeat all enemies to make the portal appear at the center of the room.
  4. Touch the portal to reload the scene and start the next room.

Project Structure

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

Configuration

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.

Known Limitations / Roadmap

  • 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

Contributing

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:).

License

This project is licensed under the MIT License.

Third-party assets such as TextMesh Pro and other Unity packages remain under their own licenses.

About

A 2D top-down survival shooter built with Unity and C#. Features player movement, mouse aiming, shooting mechanics, melee and ranged enemies, health management, coin collection, procedural room generation, and wave-based enemy encounters.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages