# Rotating Towards Object

**URL:** <https://forum.kirupa.com/t/rotating-towards-object/310426>\
**Category:** programming\
**Created:** [June 9, 2010, 8:36pm UTC](https://forum.kirupa.com/t/rotating-towards-object/310426 "2010-06-09T20:36:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![habes](https://avatars.discourse-cdn.com/v4/letter/h/e5b9ba/32.png) [@habes](https://forum.kirupa.com/u/habes)\
**Post date:** [June 9, 2010, 8:36pm UTC](https://forum.kirupa.com/t/rotating-towards-object/310426/1 "2010-06-09T20:36:30Z")

</div>

Hi Everyone,

I have a code that I am using to rotate an object towards another in my game. It works, but only seems to update periodically. When there is enough rotation for the MC to rotate about 45 degrees, then it snaps to that rotation. Any idea why this could happen? I want the MC to be constantly rotating to the proper direction.

The code, on a enter frame function:

```php
var radians:int = Math.atan2((thisParent.playerTracker.y - y),(thisParent.playerTracker.x - x));
var degrees:int = (radians*(180/Math.PI));
this.rotation=degrees;

```
