Move to target (PVector confusion)

Hi, I am trying to wrap my brain around PVectors and using them to move objects. I simply wanted my circles to start in the center and move to a random location on the canvas. I get the movement part but not the target or the subtract functions.

void update() {
target.sub(location);
target.normalize();
target.mult (.1);

velocity.add(acceleration);
velocity.limit(20);
location.add(velocity);

}

target is a PVector that contains a random x/y the velocity add and the location add get the circle moving but I cannot get it to move to the target :( Help thanks

Answers

Sign In or Register to comment.