So I’m making a top-down view game, and i’m having a little bit trouble with my character rotation.

my code for my character(Soldier) to be able to rotate facing the mouse direction is this:

```
//Code inside MovieClip Soldier
var radians:Number = 180/Math.PI;
var rotate:Number = Math.round(90 +((Math.atan2(this._y - _root._ymouse, this._x - _root._xmouse)) * radians));
_root.Soldier._rotation = rotate;
```

this is working well, but I want to achieve a cooler effect rotating only the soldier’s head with the mouse, and rotating the soldier’s body following the head’s rotation, I mean if the head rotates 10 degrees the body rotation += 5 until it has the same rotation as the head.

I’ve been playing with the code throwing some Ifs…

```
var radians:Number = 180/Math.PI;
var rotate:Number = Math.round(90 +((Math.atan2(this._y - _root._ymouse, this._x - _root._xmouse)) * radians));
_root.Soldier.Head._rotation = rotate;
if(_root.Soldier.Head._rotation > _root.Soldier.Body._rotation + 10)
{
_root.Soldier.Body._rotation += 5
}
if(_root.Soldier.Head._rotation < _root.Soldier.Body._rotation - 10)
{
_root.Soldier.Body._rotation -= 5
}
trace(_root.Soldier.Head._rotation + " " + _root.Soldier.Body._rotation);
```

This seems to work good…

now the next step and the one i having difficulty with is making the head to rotate only 180 degrees respect to the body, I mean i don’t want the head to make an exorcist type of rotation(360) if you know what I mean. One of the reasons i’m having this problem I think is cause flash movieclips rotation is based on “180,-180”… when it reaches to 180 it turns to negative and starts increasing ex: …178,179,180,-179,-178…

if anyone knows a solution for this problem I’ll really appreciate it… I’ve been working in this for 2 days… but no luck, tried searching for tutorials but none helped

i really need some help here…, if anyone can give me a clue or show me how to do it It’ll be awesome…

Cheers!