0
\$\begingroup\$

Rotating a projectile toward a target

Say I had a bullet a character shoots at an enemy. If the enemy was directly above me I want the bullet to be rotated at a 90 degree angle. Or if the bullet homed in on the target it should constantly point toward the moving target.

Can someone explain the math I need for computing the proper angle for the bullet?

\$\endgroup\$

closed as unclear what you're asking by DMGregory Jan 13 at 3:11

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    \$\begingroup\$ Are you in 2D or 3D? If 2D, have you searched for existing questions about converting a direction vector to an angle? If in 3D, have you searched for existing questions about converting a direction vector to spherical coordinates, or to a rotation matrix/quaternion? \$\endgroup\$ – DMGregory Jan 10 at 2:00
  • \$\begingroup\$ @DMGregory 2D. That sounds good. I'll go look then. Thanks \$\endgroup\$ – Kennichi Nitta Jan 10 at 2:11