W
W
wolf-98302015-02-23 10:21:44
Mathematics
wolf-9830, 2015-02-23 10:21:44

How to rotate a character?

There is a character that rotates by a given angle when drawing, we can change this angle, so the character moves along the vector, how to calculate the rotation angle so that the character is always rotated in the direction of the vector?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Huseynov, 2015-02-23
@kibergus

Use atan2 from math.h. And so, school mathematics: the sides of a right-angled triangle are given, it is required to find the angles.

V
Vladimir Tatarnikov, 2015-02-23
@Termvsrobo

First you need to initialize the coordinate system itself. In this system, you need to get the position of the character itself and the vector of the direction of movement of this character. Then we can already judge how much the direction of the required vector and the vector of the direction of movement coincide.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question