# Aiming in AS2

**URL:** <https://forum.kirupa.com/t/aiming-in-as2/301242>\
**Category:** flash\
**Created:** [December 5, 2009, 8:44pm UTC](https://forum.kirupa.com/t/aiming-in-as2/301242 "2009-12-05T20:44:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cireneikual](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@cireneikual](https://forum.kirupa.com/u/cireneikual)\
**Post date:** [December 5, 2009, 8:44pm UTC](https://forum.kirupa.com/t/aiming-in-as2/301242/1 "2009-12-05T20:44:51Z")

</div>

[SIZE=2]Hi guys,

I am making a flash game, and so far I always made my player aim his gun at the cross hair with the following code:

onClipEvent(load)  
{  
a = 0;  
b = 0;  
angleA = 0;  
Degrees = 0;  
}

onClipEvent(enterFrame)  
{  
a = (\_root.player.\_y-\_root.player.\_height/4)-(\_root.crossHair.\_y);  
b = (\_root.player.\_x)-(\_root.crossHair.\_x);  
angleA = Math.atan2(a, b);  
Degrees = angleA/(Math.PI/180)-180;

```
        _rotation = Degrees;

```

}

However, this will make him instantly aim at everything, he can rotation as fast as the player’s mouse will go. But now I am trying to reproduce the VATS effect found in fallout 3 in a 2D flash game. When I enter vats, he would just instantly aim his gun as everything, his arm just popping in the right location. So I added this code, which gives him a certain speed at which to turn. However, this code only works for one-half of a rotation, for it cannot make up for the jump from 0 to 360. The code replaces the [/SIZE][SIZE=2]\_rotation = Degrees;[/SIZE] [SIZE=2]above[/SIZE].

[SIZE=2]\_rotation += (Degrees-\_rotation)/6;[/SIZE]

[SIZE=2]Can someone help me here? I am trying to solve the 0 to 360 jump issue with if statements and it just isn’t working.

:pac:  
[/SIZE]

[SIZE=2]  
[/SIZE]
