
Missile Command is a game in which you must defend your base, composed of multiple buildings, by clicking to spawn defensive missiles to intercept and destroy enemy attackers. This article covers rebuilding this classic arcade game using Unity’s Entity Component System (ECS).
Entity Components
The implementation establishes several tag components for entity differentiation:
- Building, Missile, Defense, Player - These serve as filtering mechanisms for system queries without storing data themselves.
Data Components
Health System: Buildings track durability through a HealthInt component with current and maximum values.
Movement: Missiles utilize three components:
Speed- Movement velocityDirection- Vector indicating travel pathDamage- Impact force
Defense Mechanics: Defensive entities have a Lifetime component measuring seconds before destruction.
Collision Detection: All collidable entities use a Radius component representing the bounding volume of these entities.
Game Configuration
The GameSettings structure stores difficulty parameters including spawn rate, missile speed ranges, position boundaries, and world threshold values.
Player mechanics include:
AttackSpeed- Cooldown tracking for defense spawningScore- Point accumulation from destroying missiles
Next Steps
This article establishes the foundational data structures needed for implementation. The next installment explores systems that operate on this data architecture to create gameplay mechanics.
Source Code
Full implementation available on my GitHub repository.