This p5js project demonstrates flocking, which is a behaviour that many animals express.
It consists of alignment, cohesion, and separation. I have also added an external force which repels the boids away from the mouse.
Click to add new boids to the screen.
The base code was made by following a tutorial by The Coding Train.
Download all files as a ZIP.
Extract files into the same folder.
Open the index.html file.
Add 3D
Different coloured boids
Boids with different behaviours
Let external force be attractive as well as repulsive
Tutorial by The Coding Train on Youtube: https://www.youtube.com/watch?v=mhjuuHl6qHM