# Aim with mouse?

**URL:** https://forum.kirupa.com/t/aim-with-mouse/62408
**Category:** Uncategorized
**Created:** [August 27, 2004, 2:41pm UTC](https://forum.kirupa.com/t/aim-with-mouse/62408 "2004-08-27T14:41:51Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![cheesy\_x](https://avatars.discourse-cdn.com/v4/letter/c/eb9ed0/32.png) [@cheesy\_x](https://forum.kirupa.com/u/cheesy_x)
#### Post date: [August 27, 2004, 2:41pm UTC](https://forum.kirupa.com/t/aim-with-mouse/62408/1 "2004-08-27T14:41:51Z")

</div>

Hi, im making a top-down tile based shooter, and i was wondering how to make the character pivot and aim based on the position of the mouse…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 27, 2004, 2:52pm UTC](https://forum.kirupa.com/t/aim-with-mouse/62408/2 "2004-08-27T14:52:23Z")

</div>

read up on “radians”, and how to use them

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 27, 2004, 3:17pm UTC](https://forum.kirupa.com/t/aim-with-mouse/62408/3 "2004-08-27T15:17:25Z")

</div>

yeah shoulda done that, but i’d rather have some constructive \*\*\*\*e floating around

\*\*Its more the pivoting im worried about… I cant get it to work at the same time

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 27, 2004, 3:26pm UTC](https://forum.kirupa.com/t/aim-with-mouse/62408/4 "2004-08-27T15:26:26Z")

</div>

stick this on the bit you want to rotate, and edit the your\_mc bit to whatever youve named it:

onClipEvent(enterFrame){  
radians = Math.atan2(\_root.mouse.\_y-\_root.your\_mc.\_y, \_root.mouse.\_x-\_root.your\_mc.\_x)  
\_rotation = radians\*(180/Math.PI)  
}

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 27, 2004, 3:41pm UTC](https://forum.kirupa.com/t/aim-with-mouse/62408/5 "2004-08-27T15:41:36Z")

</div>

wait a minute, i _Think_ i know what my problem is
