In this chapter, we learned how to implement flocking behavior in two ways. First, we examined, dissected, and learned how to implement a flocking algorithm based on Unity's Tropical Island Demo project. Next, we implemented it using rigid body to control the boid's movement and sphere collider to avoid collision with other boids. We applied our flocking behavior to the flying objects, but you can apply the techniques in these examples to implement other character behaviors such as fish shoaling, insects swarming, or land animals herding. You'll only have to implement different leader movement behaviors such as limiting movement along the y axis for characters that can't move up and down. For a 2D game, we would just freeze the y position. For 2D movement along uneven terrain, we would have to modify our script to not put any forces in the y direction.
We also took a look at crowd simulation and even implemented our own version of it using Unity's NavMesh system, which we first learned...