How to make an AI calculate oblique throw correctly?

Hey guys,

I am making a sidescroller game that the AI has to calculate the correct angle to shoot and I am having a lot of trouble figuring out how to make them correctly calculate the variables.

I am trying to use formulas for a oblique throw but still can’t get a way to set the right values.
What I believe I really need is a way to the AI calculate the Intial speed (V0 in oblique throw physics), and Y and Z Velocity (Angles of cos and sen in oblique throw physics) so it can shoot correctly at the player character.

Here is what I have at the moment, In the projectile construct script. Setting the initial speed and Y and Z velocity (I don’t need X because it is a sidescroller)

I also have inside the AI Charater blueprint a event to spawn the projectile setting the values.

and I have the a way to find the nearest Player to the AI.

Thanks!