E
E
Ensiouel2019-04-03 16:30:18
Game development
Ensiouel, 2019-04-03 16:30:18

How to implement character rotation?

Suppose I have a character with 8 pictures, each of which is directed in a certain direction, that is, we will agree:
North, West, South, East
Northwest, Southeast, Southwest, etc.
And I had a question how to do so that the character turned to one of the sides, relative to the mouse cursor, it was not the picture itself that was rotated, but the desired tile was selected, I did not find it on the Internet, because I cannot correctly ask the request

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Proskurin, 2019-04-03
@Ensiouel

You can calculate the angle of the line between the character and the mouse. There is a formula
and now you have an angle from 0 to 360, you can change the sprite depending on the value of this angle.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question