I wanted to make a object move to a target when mouse is clicked how would i do this


#1

void setup(){
size(500,500);
}

void draw(){
fill(0);
rect(100, 200, 40, 40);
fill(255,0,5);
rect(400, 400, 40, 40);
}


#2

A point that follows the mouse put this in mouseClicked()
or you can look at this and adapt it to waht you need (put this inside mouseClicked() too)