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

**URL:** <https://discourse.processing.org/t/i-wanted-to-make-a-object-move-to-a-target-when-mouse-is-clicked-how-would-i-do-this/7365>\
**Category:** Coding Questions\
**Created:** [January 9, 2019, 6:17pm UTC](https://discourse.processing.org/t/i-wanted-to-make-a-object-move-to-a-target-when-mouse-is-clicked-how-would-i-do-this/7365 "2019-01-09T18:17:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![redFoa](https://avatars.discourse-cdn.com/v4/letter/r/e274bd/32.png) [@redFoa](https://discourse.processing.org/u/redFoa)\
**Post date:** [January 9, 2019, 6:17pm UTC](https://discourse.processing.org/t/i-wanted-to-make-a-object-move-to-a-target-when-mouse-is-clicked-how-would-i-do-this/7365/1 "2019-01-09T18:17:20Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![Sky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sky/32/3013_2.png) [@Sky](https://discourse.processing.org/u/Sky)\
**Post date:** [January 9, 2019, 6:20pm UTC](https://discourse.processing.org/t/i-wanted-to-make-a-object-move-to-a-target-when-mouse-is-clicked-how-would-i-do-this/7365/2 "2019-01-09T18:20:07Z")

</div>

[A point that follows the mouse](https://forum.processing.org/one/topic/how-do-i-get-objects-to-follow-a-separate-moving-object.html) put this in [mouseClicked()](https://processing.org/reference/mouseClicked_.html)  
or you can look at [this](https://processing.org/examples/easing.html) and adapt it to waht you need (put this inside mouseClicked() too)
