2
$\begingroup$

I have an object and an angle value (clockwise) in my game.

Depending on the angle, the object will move toward a certain direction.

If the angle is 0, the object will move (0,1) per frame (x,y) where positive y is "up". If the angle is 90, the object will move (1,0). If the angle is 45, the object will move (1,1). Decimal values are possible for accuracy (all values will range from 0.0 to 1.0).

But, what steps am I supposed to take to calculate such values. Any ideas?

2 Answers 2

2

If the angle is $\omega$ from the y-axis (clockwise) then you should take steps exactly $(\sin(\omega), \cos(\omega))$, i.e. $\sin(\omega)$ in the x-direction and $\cos(\omega)$ in the y-direction. For example, for $\omega = 45^o$ this gives exactly $(\frac{1}{2} \sqrt{2},\frac{1}{2} \sqrt{2})$ (which is $(1,1)$, normalized at length $1$) while for $\omega = 90^o$ we get $(1,0)$.

2

I would use the Unit Circle and keep putting the origin as your last point, i.e. if you move up 90, now your origin of the circle is $(1, 0)$ and use the circle again. Also, to keep things symmetric, the angle 45 should go to $(\sqrt{2}/2, \sqrt{2}/2)$, not $(1, 1)$.