Flocking AI - I tried, failed, then succeeded

Below is what Cohesion, Alignment and Separation look like all working together...

Below is Cohesion, which moves to the average location of nearby units... This simply just makes everything group together in the centre...

Next up is Alignment, this forces each unit to move in the same direction as other nearby units by taking into account their velocities and direction of movement...

Finally Separation is literally just moving each unit in the opposite direction to the average position calculated using nearby unit positions...



As for what I failed at doing previously, see the gif below... I abandoned what I tried to do in Unity and found a way to do what I wanted via Processing.js

And...

Tom Lynn

Read more posts by this author.

Australia http://rubbix.net