Projectile: initial velocity angle to hit coordinate.

Categories code, physic

While working on an aiming system for one of my games, I faced this problem: “What should be the initial velocity angle for a projectile to hit given coordinate?” I wanted the bullet to pass thru mouse position. This image illustrates the problem:

Projectile angle to hit coordinate

The projectile should hit coordinate marked with red cross. The launcher has fixed power and bullets have fixed mass, so in my scenario the initial velocity vector length will be constant (I will adjust it accordingly to get nice gameplay). The intuition says that I’ll end up with more than one trajectory. One will hit the coordinate after reaching maximum height and another will use the shortest parabolic path. Continue reading “Projectile: initial velocity angle to hit coordinate.”