Hey guys this is my first post and I would like to start of by saying Hello.

So Hello

Anyways, I'm currently programming a 2D game and am having a few difficulties on working out an equation, or finding an equation that is. I'll give you some details of what it is.

Basically, I'm building an AI that fires its artillery gun at a target in the distance. But I need to find out how mathematically wise it would do this. There are 3 key elements to it. The first being the distance between the AI and its target, the second being the gravity that is implemented in the game and the angle in which it needs to find to hit the target. If I know the equations ill be able to implement it within the code.

Does anybody on here know how you would work out the angle in order for the AI to hit it's target?

Thanks for any help