A simple tower defense game built with Unity. This repository contains the Unity project, gameplay scripts, scenes, and assets used to prototype tower placement, wave-based enemy spawning, and projectile attacks.
- Buildable nodes with hover material and position offsets (Scripts/Node.cs)
- Turret placement and firing projectiles (Scripts/Arrow.cs)
- Enemy prefabs and wave-based spawning with scaling difficulty (Scripts/EnemySpawner.cs)
- Enemy movement along waypoints and life handling (Scripts/EnemyMovement.cs)
- Range indicator toggling for towers (Scripts/ShowRange.cs)
- Basic materials, sprites, and animator controllers included in the project
-
Prerequisites
- Install Unity Hub: https://unity.com/download
- Install a Unity Editor version compatible with the project (recommended: Unity 2021.3 LTS or later). If you have the project on disk, check ProjectSettings/ProjectVersion.txt for the exact version.
- Git (for cloning the repository)
-
Clone the repository
git clone https://github.com/Jamwilltim/Tower-Defence-Game.git
cd Tower-Defence-Game-
Open the project in Unity
- Launch Unity Hub
- Click Add, select the repository folder you cloned
- Open the project with the installed Unity Editor version matching the project's ProjectVersion.txt
-
Open the main scene
- In the Unity Editor, open Scenes/MainScene.unity
- Press Play in the Editor to run the scene
- Left-click on buildable Nodes to place a turret (if you have enough currency)
- Towers will target enemies and fire projectiles automatically
- Enemies follow waypoints and reduce player lives if they reach the end
- Waves increase in size/difficulty according to the values in Scripts/EnemySpawner.cs
- Assets/
- Scenes/ - Unity scenes (MainScene.unity)
- Scripts/ - C# scripts (Node.cs, EnemySpawner.cs, EnemyMovement.cs, Arrow.cs, ShowRange.cs, etc.)
- Prefabs/ - Prefabs for turrets, hover blocks, etc.
- Sprites/ - Sprite sheets and animation controllers
- Materials/ - Material assets (ground.mat)
- EnemySpawner contains configuration you can tune in the Inspector or directly in the script:
- baseEnemies
- startCountdown
- enemiesPerSecond
- timeBetweenWaves
- difficultyScalingFactor
- enemiesPerSecondCap
- Missing or mismatched Unity version: If the Editor reports an incompatible version, install the matching Editor via Unity Hub or use the closest LTS release.
- Missing packages: Open Window > Package Manager and add any required packages listed in Packages/manifest.json.
- NullReferenceException or missing references: Inspect the GameObjects in the scene and verify required components (e.g., sprite renderers, references to prefabs, spawn points) are assigned in the Inspector.