So the equation i used was :

e = Sqrt(1+(2(((v^2/2)-((G(M1+M2)/r)))*(r*(m*v)^2)))/((1/((1/M1)+(1/M2)))*(G(M1*M2))^2)) which should be the expanded form of e = Sqrt(1+((2(E*L^2))/(mred*a^2))) but this isn't working. Where

v = velocity

G = Grav. Constant

r = distance

m = M1

E = orbital energy

L = angular momentum

mred = reduced mass

a = coef. of inverse-square law

So maybe i missed a variable or something. So have any ideas on what is wrong? Ohh and to get velocity i used a built in Unity function to find velocity so i don't need to calculate for that.