Okay so I'm using the mouse to control a virtual joystick
onscreen that then moves a character. I'm using this code below to
generate the direction and it works fine when restricted to up/down
and side to side moves but I want to a)move diagonally and b) make
sure the character is correctly rotated in the direction of the
Below is the code I'm using where I generate an angle from
the start (pStartPos) and current (my.loc) positions of the control
ang = atan( dy, dx ) * 180 / PI
angleDegrees = ang + 180
So I want to understand (maybe that's a tall order but...)
how to convert my outcome to relative horizontal and vertical
movements and how to set the rotation for that.
I never did trig the first time round so this is from a
> ang = atan( dy, dx ) * 180 / PI
> angleDegrees = ang + 180
> So I want to understand (maybe that's a tall order
but...) how to
> convert my outcome to relative horizontal and vertical
> how to set the rotation for that.
> I never did trig the first time round so this is from a
It isn't clear to me exactly what you're asking, but...
where r is the distance from (0,0) and t (you'll often see it
as the Greek
letter theta) is the angle anti-clockwise from the x-axis.
Remember, Director's y-axis is upside-down compared to the
maths, so positive and negative angles go the