KAgent wander
From KokkugiaWiki
this method adds a random steering vector to acceleration (acc), the vector is a certain degree of random change from the existing vector by steering towards a new point located on a circle whose center is at the end of the current velocity (vel) vector. this method accepts no arguments.
// wander - currently only working in 2d
void wander() {
// make this 3D
float wanderR = 8;
float wanderD = 60;
float change = 0.1;
wandertheta += random(-change,change);
kVec circleloc = kVec.clone(vel);
circleloc.normalize();
circleloc.scale(wanderD);
circleloc.plus(pos);
kVec circleOffSet = new kVec(wanderR*cos(wandertheta),wanderR*sin(wandertheta));
circleOffSet.plus(circleloc);
acc.plus(steer(circleOffSet, ht));
}
