Hello people. I’m following the Nature of Code 2 video about Flee (https://editor.p5js.org/codingtrain/sketches/v-VoQtETO) and I’m having some confusion about the following part of the code in the definition of the class Vehicle:
return this.seek(target).mult(-1);
}
seek(target) {
let force = p5.Vector.sub(target, this.pos);
force.setMag(this.maxSpeed);
force.sub(this.vel);
force.limit(this.maxForce);
return force;
}```
I think conceptually the “flee” function is supposed to make sure that the desired velocity of the vehicle points away from the target, therefore the flee desired velocity = seek desired velocity * (-1), correct? But seems in the code above rather it is the steering force that is being flipped instead by the *(-1)…I don't think they are equivalent. Is my thinking correct? Appreciate your input as always 😉
A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.