Get angle between two scalar inputs

23 Views Asked by At

I'm trying to make a game and in m working on the movement system

I'm trying to make the character look the way they are moving

I have two numbers, the horizontal axis and vertical axis; both are between -1 and 1

What I need is the angle that the point (h, v) is at

I would prefer the math to be linear as I am using bolt which is a flow language

1

There are 1 best solutions below

0
On BEST ANSWER

The usual function for this is called atan2 in most programming languages. So $$\theta=atan2(y,x)$$ should give the angle (usually in radians) between the ray going from the origin to the point $(x,y)$ and the positive x-axis.

The function works for any point except of course the origin $(0,0)$, because then the angle is undefined.