I want to make a symbol rotate to point at the mouse. I'm using this function, but it doesn't work below the symbol's pivot. The inverse tan function has a range of 180 degrees right? So how can i get 360 degrees of movement?
Would I need to add an if statement to check the mouse position or is there a more elegant solution?
function panelTrack(){
angle = -180/Math.PI * Math.atan((mouseX - panel.x)/(mouseY - panel.y));
panel.rotation = angle;
trace(panel.rotation);
}
const radiance:Number=180/Math.PI;
angle=-(Math.atan2(mouseX-panel.x, mouseY-panel.y))*radiance;
I used minus because usually the orientation is reverse when you don't add minus.
hope this helps.