This project implements a boids simulation in Unity using the Entity Component System (ECS).
Its goal is to explore high-performance by applying Data-Oriented Design (DOD) principles.
I implemented the system in both Object-Oriented (OOP) and ECS styles to compare their performance and efficiency.
A boid is an autonomous agent following simple rules of alignment, separation and cohesion to simulate flocking behavior see more
- Architecture: Pure DOTS using Entities 1.0, Burst Compiler, and the Job System.
-
Flocking Logic: Currently uses a naive
$O(N^2)$ approach (brute-force neighbor check) inside a parallelIJobEntity. - Movement: 2D logic on the X/Z plane with Y-axis rotation.
- Obstacle Avoidance: Uses Unity Physics with a "Whisker" raycast system to scan angles and steer around static geometry.
- Architecture: Standard
MonoBehaviourscripts attached to GameObjects. - Logic: Single-threaded
Update()loops. - Purpose: Serves as a performance baseline to demonstrate the limitations of traditional Unity architecture when handling hundreds of autonomous agents.
Current Issue: The simulation checks every boid against every other boid
Solution: Implement a Spatial Hash Grid:
- Boids will be bucketed into grid cells based on position.
- Queries will only check the specific cell and immediate neighbors.
-
Goal: Reduce complexity to
$O(N)$ to support thousands of entities.
- Unity 6 (version: 6000.0.58f2)
Made by: Vincent DEVINE
Character Asset: Starter Assets - ThirdPerson by Unity
Building Asset: City Kit by kenney
Implementation of the OOP architecture is based on Sebastien Lague's work on boids
Implementation of the ECS architecture is based on Unity's work on the ECS Samples
