diff --git a/Assets/Boid.cs b/Assets/Boid.cs index 7ccc76c..022e3ae 100644 --- a/Assets/Boid.cs +++ b/Assets/Boid.cs @@ -5,7 +5,7 @@ public class Boid { private Vector2 _position; private Vector2 _velocity; - Boid(Vector2 position, Vector2 velocity) { + public Boid(Vector2 position, Vector2 velocity) { _position = position; _velocity = velocity; } @@ -20,7 +20,7 @@ public class Boid { } // Returns the next position the Boid will be moving to - Vector2 NextPosition(List boids, float[] magnitudes) { + public Vector2 NextPosition(List boids, float[] magnitudes) { // Find the local flock List flock = GetFlock(boids, 5); diff --git a/Assets/BoidController.cs b/Assets/BoidController.cs index 8a7f6bb..e3486d0 100644 --- a/Assets/BoidController.cs +++ b/Assets/BoidController.cs @@ -18,11 +18,17 @@ public class BoidController : MonoBehaviour { private List _boids = new List(); void Start() { - + for(int i = 0; i < boidCount; i++) + _boids.Add(new Boid(Vector2.zero, new Vector2(1, 1))); } - void Update() - { - + void Update() { + float[] magnitudes = new float[] {cohesionBias, separationBias, alignmentBias}; + // Update all Boid positions + foreach (Boid boid in _boids) { + boid.SetPosition(boid.NextPosition(_boids, magnitudes)); + } } + + }