Calculating a projectile arc

Hi!

I’ve been struggling with this concept for months now and getting around it by using a more simple aiming system which only works half of the time.

In my game the player fires liquid projectiles (in the form of particles), thus naturally they arc unlike a bullet so I need the aiming system to compensate for this.

The below image illustrates what I’m trying to accomplish:

alt text

The white Debug Line is a raycast along the gun’s line of sight, and is where the player is aiming.

The 3 arcs show how the weapon would need to angle itself in order to shoot each target that the raycast hits. How would I go about calculating this angle?

Thanks in advance for any help/advice!

The angle of a projectile launch (A) with known parameters initial velocity (V), target distance (x), and gravity (g) is given by

A = 0.5 arcsin(gx / V^2)

For example, the angle for a launch at 50 units per second for a target distance of 200 units with gravity of 9.81 units per second is given by

A = 0.5 arcsin(9.81 * 200 / 100^2) = 25.85 degrees