PDA

View Full Version : Rotating Towards Object



habes
June 9th, 2010, 04:36 PM
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:

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

justkevin
June 9th, 2010, 08:50 PM
Change radians from int to Number (you should probably change degrees as well, but that will have a much less notable effect).

habes
June 9th, 2010, 09:45 PM
Change radians from int to Number (you should probably change degrees as well, but that will have a much less notable effect).

Ah duh, thank you very much.