diff --git a/Boid.pde b/Boid.pde index 6bb1a67..e8fac3c 100644 --- a/Boid.pde +++ b/Boid.pde @@ -126,11 +126,10 @@ class Boid dotProductOfTargets = (dotProductOfTargets + 1) / 2; //use an ideal speed for our boid, to tell it to either speed up or slow down whether it's going faster than this or not - //Square the dot product that's been normalized; it'll change the curve so it slows down more float idealSpeed = (dotProductOfTargets) * 80 + 15; float maxSpeed = 100 * pow(((PI - abs(angleToTarget)) / PI), 10); - println(maxSpeed); + //println(maxSpeed); if (idealSpeed > maxSpeed) { idealSpeed = maxSpeed; @@ -148,23 +147,17 @@ class Boid //kinematic.getSpeed() is how fast we're moving, direction.mag() is how far are we from target //Ideal speed here should be 80 at dist 85, and reduce linearly from there, hitting 0 at 5 units? //This can be changed later if it isn't good - + + float idealSpeed = (1 * direction.mag() - 5); - - //if idealSpeed is "negative" we should just set it to 0 + if (idealSpeed < 0) { idealSpeed = 0; } - //use this to know how off the target speed we are, and slow down accordingly - //This will be positive if the ideal speed is higher than current speed, negative if ideal speed is lower. - float speedOffset = (idealSpeed - kinematic.getSpeed()); - - if (abs(speedOffset) < 1) { - kinematic.increaseSpeed(speedOffset, 0); - } else if (idealSpeed < speedOffset) { + if (kinematic.getSpeed() < idealSpeed) { kinematic.increaseSpeed(1, 0); - } else if (idealSpeed > speedOffset) { + } else if (kinematic.getSpeed() > idealSpeed) { kinematic.increaseSpeed(-1, 0); } } @@ -179,7 +172,7 @@ class Boid //Ideal speed here should be 80 at dist 85, and reduce linearly from there, hitting 0 at 5 units? //This can be changed later if it isn't good - float idealSpeed = 1 * direction.mag() - 5; + float idealSpeed = 1 * direction.mag() + 10; //if idealSpeed is "negative" we should just set it to 0 if (idealSpeed < 0) {