# How to make an object face the mouse in Canvas?

**URL:** <https://forum.kirupa.com/t/how-to-make-an-object-face-the-mouse-in-canvas/641330>\
**Category:** web dev\
**Created:** [December 13, 2019, 6:30pm UTC](https://forum.kirupa.com/t/how-to-make-an-object-face-the-mouse-in-canvas/641330 "2019-12-13T18:30:55Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [December 14, 2019, 9:40pm UTC](https://forum.kirupa.com/t/how-to-make-an-object-face-the-mouse-in-canvas/641330/5 "2019-12-14T21:40:26Z")

</div>

Glad to hear you are unblocked 😀

There are several things with the SO solution that aren’t ideal. I wouldn’t use the slower `getBoundingClientRect` to get the mouse position relative to any offsets on the page. I would use `getMousePosition` from here: [https://www.kirupa.com/canvas/follow\_mouse\_cursor.htm](https://www.kirupa.com/canvas/follow_mouse_cursor.htm)

There are a few areas where I would just use `requestAnimationFrame` instead of _mousemove_, and I will try to provide you with a working solution in a couple of days.

---

_[View the full topic](https://forum.kirupa.com/t/how-to-make-an-object-face-the-mouse-in-canvas/641330)._
