SwarmLabECS is a highly optimized, modular Unity package designed for simulating massive, complex swarm behaviors (flocking, schooling, and crowd movement) using Unity's Data-Oriented Technology Stack (DOTS).
Built entirely with the Entity Component System (ECS), the Burst Compiler, and C# Job System, SwarmLabECS can handle tens of thousands of entities at 60+ FPS. It utilizes Spatial Hash Grids for heavily optimized
- Performance: Simulate 30,000+ boids smoothly via Burst-compiled, multithreaded Jobs and Spatial Partitioning.
- Interaction Matrix: Support for multi-species ecosystems. Fine-tune Cohesion, Alignment, and Separation weights independently for how each species reacts to itself and others.
- Environment Adherence: Built-in "Hovercraft" physics using Hooke's Law (Spring and Damping) via ECS Raycasts to smoothly snap entities to complex terrain and colliders.
- Flexible Spawning: Uniform volumetric spawning supporting both spherical and cubic zones.
- Data-Oriented Architecture: Clean separation of Authoring components and ECS Runtime systems, making it highly modular and safe to drop into any project.
- Unity Version: 6000.2 or later.
- Dependencies:
com.unity.entitiescom.unity.burstcom.unity.mathematicscom.unity.physicshttps://github.com/dbrizov/NaughtyAttributes.git#upm
- Open the Unity Package Manager.
- Click the
+button in the top left. - Select "Add package from git URL..."
- Paste the following URL:
https://github.com/xaxam2001/SwarmLab-ECS.git?path=/SwarmLabECS-UPM - NAUGHTY ATTRIBUTES: please note that naughty attribute is a necessary dependency for this package you can install via this link:
https://github.com/dbrizov/NaughtyAttributes.git#upm
If you want to modify the package source code:
- Download the repository as a ZIP or Clone it.
- Copy the
SwarmLabECS-UPMfolder into your Unity project'sPackagesfolder (or anywhere in your project assets). - Open the Unity Package Manager.
- Click the
+button in the top left. - Select "Add package from disk...".
- Select the
package.jsonfile inside the folder you just copied.
- Add an empty Unity subscene into your scene.
- Create a Prefab and add the
EntityAuthoringscript to it. Ensure it has a Mesh and Material. - Create an Empty GameObject in your subscene and add the
SwarmManagerandSwarmConfigAuthoringscripts. - In the
SwarmConfigAuthoringcomponent, add a new Species, assign your Prefab, and configure the spawn count, max speed, and interaction rules. - Ensure your environment has a Unity Physics Collider attached and is baked into an ECS SubScene (if using Gravity/Raycasting).
- Enter Play Mode and click "Generate Swarm" in the SwarmManager Inspector.
See DOCUMENTATION.md for full details on ECS workflows, component data structures, and advanced configuration.