fix last target code because i broke it

This commit is contained in:
JH159753 2022-11-02 02:26:04 -07:00
parent 7851363a56
commit b673d12089
1 changed files with 7 additions and 14 deletions

View File

@ -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) {