I have this formula for projectile motion that I'm using in Unity for getting the low or high direction of a shot, and it works. However, I'd love to understand the equation.
And notably,
- Why
forcewas raised to the power of 4? - How to understand what's happening in
P? - For the
lowandhighvectors, how did it manage to get the right angles? - What formula in Projectile Motion was this derived from?
Vector3 dir = target - origin;
float v2 = force * force;
float v4 = v2 * v2;
float g = -Physics.gravity.y;
float x = dir.x;
float y = dir.y;
float P = v4 - g * (g * x * x + 2f * y * v2);
float sq = Mathf.Sqrt(P);
low = new Vector3(g * x, v2 - sq);
high = new Vector3(g * x, v2 + sq);
Apologies as I'm not well-versed with many math equations e.q. trigo, calculus, even though I'm a programmer.
I hope you understand my plight and thanks in advance.