Pong in Unity ECS
This article documents rebuilding the classic game Pong using Unity’s Entity Component System (ECS) framework. The game features a ball and two paddles—one player-controlled, one AI-controlled—where players earn points when opponents miss the ball. Entity Components The implementation defines four key component structures: [GenerateAuthoringComponent] public struct PongPaddle : IComponentData { } [GenerateAuthoringComponent] public struct Ball : IComponentData { } [GenerateAuthoringComponent] public struct AI : IComponentData { } [GenerateAuthoringComponent] public struct Speed : IComponentData { public float value; } Player Paddle Movement System The player paddle responds to vertical input (up/down axes) and constrains movement within bounds: ...
One vs Many
This article explores rebuilding a “One vs Many” style game using Unity’s Entity Component System (ECS). ECS enables spawning thousands of enemies while maintaining strong CPU performance—ideal for games where a single player faces numerous adversaries. Core Entity Components The game uses three main entity types defined through component data structures: Player, Bullet, and Enemy Components: Players track score Enemies have point values Bullets maintain active status and age tracking Movement and Health Systems: The implementation uses shared components for movement (direction and speed) and health tracking using integer or float values. Damage components handle collision effects. ...
Missile Command in Unity ECS Part 2: Systems
This article explores the systems architecture for rebuilding the classic game Missile Command using Unity’s Entity Component System (ECS). Here I describe the systems required to manage game entities and their interactions. Key Systems Missile Creation and Movement The MissileSpawnSystem generates enemy missiles at randomized positions and directs them toward player buildings. In order to create a challenge in the game, we have to spawn the enemy missiles in randomized positions and move them directly toward the player’s buildings. ...
Missile Command in Unity ECS Part 1: Entity Data
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. ...
Memory Game in Unity ECS
This post details the creation of a classic Memory card matching game using Unity’s Entity Component System (DOTS). The implementation challenges players to find matching card pairs by remembering their positions. Key Components Card Data Structure The foundation uses a Card component storing: Value: Internal identifier for matching logic Face: Entity reference to the visual representation A companion CardAuthoring class enables inspector-based configuration rather than hard-coding values. ...
Conway's Game of Life in Unity ECS
Created in 1970 by mathematician John Horton Conway, this cellular automaton simulation operates on a 2D grid where cells evolve based on three rules: Any live cell with 2 or 3 neighbors survives Any dead cell with 3 live neighbors becomes alive All other cells follow standard death/stasis patterns Core Data Structures The implementation uses component-based architecture with these key structures: LifeStatus Component: Tracks whether a cell is alive (1) or dead (0) ...