This is my take on the legendary flocking algorithm developed by Craig Reynolds in 1986. The idea being that if we program agents to follow three simple rules, from it emerges beautiful, collective, flock-like behaviour.
The three rules being:
- Separation: steer to avoid crowding local flockmates
- Alignment: steer towards the average heading of local flockmates
- Cohesion: steer to move towards the average position of local flockmates
To run this you'll need Unity version 2020.3.7f1.
Oh and I added the feature for the agents to avoid obstacles, too.