This project implements a performant and scalable boid-like flocking system in Unity using the C# Job System and Burst Compiler. Each unit is a MonoBehaviour
, but its logic is parallelized using IJobParallelFor
, enabling efficient behavior updates for large numbers of agents.
- Parallelized movement updates using Unity's C# Job System
- Behavior logic:
- Cohesion: move toward local flockmates
- Avoidance: steer away from nearby agents
- Alignment: match heading with nearby agents
- Bounds: steer back toward center of flock area
- Randomized flock parameter generation
- Burst Compilation for optimized math-heavy operations
NativeList<T>[]
used to store per-agent neighbor data- Inspector-exposed fields for behavior weight tuning
- Units are spawned randomly in a bounded 3D area.
- In
Update()
, each agent gathers its nearby neighbors intoNativeList<T>[]
buffers. - These buffers are currently prepared but not yet fed into the
MoveJob
system. - A
MoveJob
runs with placeholder arrays to update movement vectors in parallel. - Final positions/rotations are applied back to each GameObject after the job finishes.
- Attach
Flock.cs
to a GameObject in the scene. - Assign the
FlockUnit
prefab. - Tweak behavior weights and distances in the Inspector.
- Play the scene to see units move with basic flocking logic.