The math is quite large. I copied it from a previous project.
Draw a quadratic curve and a point on the curve.
It doesn’t matter how you fire the projectile as long as the test projectile is fired in the same direction and with all the same settings. So, the test projectile follows the same path as the real projectile.
The principle is simple. I’m honestly amazed it works. It continually fires cannon balls based on the cursor. I added a timer to reduce the nedded resources. It can be set to whatever.
When a ball reaches the top of its arch the Y velocity changes from a negative to a possitive. It seems backwards but that’s because Y starts at the top. So, as it goes up, the Y value goes down. So, when the ball starts to drop on the screen, the Y is actually increasing.
So, when it starts to drop, it’s half way through it’s path. The x and y are saved and the drawline is set to true. The dropping boolean variable isn’t actually needed. It was from a previous version before I decided to just delete the test ball. I believe that can be removed.
With the center point set to control point x, y then the rest of the events calculate an adjusted control point for a quadratic curve. A quadratic curve is based on 3 points. A start, end and a control point.
Normally, the control point creates a curve that doesn’t go through the control point but the remaining functions calculate the math to draw through the point. The end point is calculated as center distance times 2.
The formula can definitely be optimized. I don’t fully understand the equation. It’s not mine. But I know how to make it work. I used extra variables because that’s how. It was written plus I was using old events with now events. It also makes it easier to write and read.
This is how it would normally draw it.

The the last 3 draw circle actions are just for testing.
I hope this helps.