Answers for "Math Genius NEEDED! Algorithm problem with parabola"
http://answers.unity.com/questions/1382704/math-genius-needed-algorithm-problem-with-parabola.html
The latest answers for the question "Math Genius NEEDED! Algorithm problem with parabola"Answer by Bunny83
http://answers.unity.com/answers/1382942/view.html
Well first of all "g" should be the value of the acceleration. This should be positive. There is no direction information in a single value. You seem to use the y component of the Physics gravity vector which is usually negative.
Next thing is the formula you use only works when both your firePoint as well as your target are on the exact same height. Also keep in mind when you rely on Unity's physics engine for the actual simulation that this assumes no drag at all.
You also need to check if the term inside ASin is not lower than "-1" or greater than "1", In that case the target can't be reached at all. Also ASin would return a NaN in that case.
If the height of the two points can be different you have to use [this one][1] instead. Of course here a similar check has to be done. You can only reach the target when the root has a real value (i.e. the value inside the root has to be 0 or positive). If the root is a complex root the target can't be reached,
Finally what do you actually pass to your "Fire" method? Currently you pass the distance between you and the target. Shouldn't you somehow pass the angle?
ps: Never use "pow" for simple powers. This `(Mathf.Pow(v_, 2))` should be simply
`(v_ * v_)`
[1]: https://en.wikipedia.org/wiki/Trajectory_of_a_projectile#Angle_.7F.27.22.60UNIQ--postMath-00000010-QINU.60.22.27.7F_required_to_hit_coordinate_.28x.2Cy.29Sat, 22 Jul 2017 20:54:05 GMTBunny83