Hello all, I am using the following equation from Wikipedia: 
to calculate the required angle of my projectile to reach a point projected to 3D space from the cursor. I’m sure this would be working perfectly if Unity didn’t keep seemingly messing up the math.
The following is an example script, what it gets, and what I get (from my head and a TI 83 calculator):
var x = 5; // x = 5 Distance to target
var v = grenadeForce; // v = 500 Projectile speed
var g = Physics.gravity.y; // g = -9.81 Gravity
//Debug.Log(g);
var gx2 = g * (x*x); // Unity and I both get -245.25
//Debug.Log(gx2);
var yv2 = 2 * 0 * (v*v); // Unity and I both get 0
//Debug.Log(yv2);
var inPar = gx2 + yv2; // Unity and I both get -245.25
//Debug.Log(inPar);
var minus = g * inPar; // Unity and I both get 2405.903
//Debug.Log(minus);
var sqrt = (v*v*v*v) - minus; //I get 6.249999759e10
Debug.Log(sqrt); //Unity gets -1.924512e9
Why is it that I get 6.24… for the pre-sqrt-ed number, but Unity is getting something completely different? In fact, it’s so different, the complete function can’t even return a real angle to fire with.
You might update or edit your original question instead of posting a new question as an answer; but I don't think there's anything wrong : trajectories will have two answers in general above and below 45 degrees, so 89 (nearly straight up) and 1 (just above horizontal so that it immediately hits ground) seem to agree with your conditions of 500 (very fast) and 5 (don't go very far). If you want your projectile to start from above ground, or not be in a flat plane of insta-stop material, then you need a better model / equation. In other words, what numbers are you expecting here?
– hatshapedhatApologies, first time on Answers. Believe it or not, 500 isn't all that fast. And 5 is actually a decent distance from my model, being only ~1 in size. I am of course using rigidbody.AddForce(direction * force). Oh, and the 89 answer literally goes above my model's head and straight back through it, there is next to no lateral movement. Is it possible that rigid body force is not the same as real world velocity? Or do you think my scale is so small the gravity is off?
– IR_NiftyAh... So you suggest that changing the ForceMode will allow my force to become my velocity? Or should I find some number to decide my force by and feed that to my algorithm?
– IR_NiftyYes, sure. Add Force is also a bit risky since it doesn't enforce an absolute velocity but add an force which will result in an velocity change.
– Bunny83