Implementing the FlockController

The FlockController is going to handle the orchestration of the entire flock. There is a quite a bit going on here in terms of variables. Let's take a look at FlockController.cs chunk by chunk:

private int flockSize = 20;

Here, we simply assign the size of our flock. You'll see this value being used up ahead in the Awake method:

private float speedModifier = 5;[SerializeField]private float alignmentWeight = 1;[SerializeField]private float cohesionWeight = 1;[SerializeField]private float separationWeight = 1;[SerializeField]private float followWeight = 5;

We then declare a series of modifier and weight values. speedModifier directly affects how fast our boids can move. Tweak this as needed. The three values ...

Get Unity 2017 Game AI Programming - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.