3
\$\begingroup\$

I have such question:

how to calculate angle between player and end point?

Things, which i have:

  1. Player. I have X, Y, Z position of player and his Z-angle (0-360)

  2. Endpoint. I have only X, Y, Z position of end point.

Task:

Rotated player Z-angle to end point.

How i can did this?

Please, help :3

\$\endgroup\$
2
\$\begingroup\$

If I understand you correctly, you want

z_angle = atan2(target_y - player_y, target_x - player_x);
\$\endgroup\$
  • \$\begingroup\$ Don't forget to take the player's current facing angle into account! \$\endgroup\$ – DMGregory Jan 1 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.