Post: Action Script 3.0. Player Rotation
06-04-2012, 01:21 PM #1
(adsbygoogle = window.adsbygoogle || []).push({}); I am trying to make my character rotate so he is always looking at the mouse. It rotates 20 degrees then stops.

This is my code i am using to get him to rotate.

public function playerRotate():void {

var xlength:Number = mouseX - this.x;
var ylength:Number = mouseY - this.y;

var angle:Number = Math.atan2(ylength, xlength) *180/ Math.PI;
trace(angle + "angle");

this.rotation = angle;

}

I don't get any errors from this code.


Screen Shots of character Rotation When mouse is at (TOP LEFT, TOP RIGHT, BOTTOM RIGHT, BOTTOM LEFT)

[ATTACH=CONFIG]17361[/ATTACH][ATTACH=CONFIG]17362[/ATTACH][ATTACH=CONFIG]17363[/ATTACH][ATTACH=CONFIG]17364[/ATTACH]

If you need to look through all my programming to find problem. Private message I'll add you on Skype.
(adsbygoogle = window.adsbygoogle || []).push({});

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo