Answer the question
In order to leave comments, you need to log in
Does the problem of rotating a sprite depending on the coordinate axes of movement have a solution?
I want to write a universal function for the dependence of the rotation of the character sprite on the value of the control axes.
Namely:
We have two axes:
X (horizontal) and Y (vertical), respectively,
The angle of rotation of the sprite depends on the coordinates (see figure)
According to these data, I picked up a functional dependence, but it works only in 50% of cases (at zero points)
The resulting function in EXEL looks like:
=ABS(((A2+2)*-90)*A2)+ABS(((B2*90)-90)*-1*B2
) the only function will be in transform.rotate(0,0,FUN) (Unity code)
Is there a solution to this problem? Or you have to register the change in the angle of the sprite when you press the keys ...
Answer the question
In order to leave comments, you need to log in
It's not very clear (in particular: a pair of x and y can only take 8 values?), but it seems that you need the atan2 function. Just keep in mind that it, as expected, assumes that zero degrees is in the positive direction of the x-axis.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question