Skip to content

Vincent-Devine/Boids

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Boids

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

boid

Table of Content

Implementation

ECS Implementation

  • 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 parallel IJobEntity.
  • 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.

Object Oriented Design Implementation

  • Architecture: Standard MonoBehaviour scripts 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.

Improvement

Current Issue: The simulation checks every boid against every other boid $O(N^2)$, causing performance to drop quadratically as population grows.
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.

Technology

Credit

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

About

Boids implementation with Unity ECS

Topics

Resources

License

Stars

Watchers

Forks

Languages