Got a function that uses a lot of trig
It used to quite regularly return Vector3(NaN, NaN, NaN) when on a flat (Vector3 == Vector3.Up) even though it shouldn't.
So I added the if (groundNormal == Vector3.up) return Vector3.zero; part and it got rid of most of the errors. But I still get the very rare occasional one and I'd like to get rid of it.
Bonus Question which will probably solve original question so I'll leave it in same answer. Haven't really done vectors/trig in maybe 6 years so I'm a bit rusty. But does anyone know how to rewrite my function a lot cleaner? I'm pretty sure there are ways to do it using cross products etc. Pretty much the function is manually calculating the force in the x,y,z direction on a slope for gravity.
Think I've solved this by adding
Up the top. Guess normal was returning a number marginally over 1 due to floating point error or something.
answered Mar 04 '11 at 12:02 AM