# Gravity simulation not accurate. Can't understand why

Hello

What I am doing is creating a simple, moderately accurate simulation where you can control a spacecraft. Anyway, to test my physics i created the Earth and the ISS, but made them 100000 times smaller, so instead of the earth being 12742000 meters in diameter, i have made it 127.42 and the distance between earth and ISS is 4 in stead of 400000 meters. Anyway, to make this scaling work in the universal law of gravitation, I have scaled the mass of the of the earth down by 10000000000 because the distance is squared in the equation of universal gravitation (Fg = G(Mm/r^2)) and then so is the scaling. Which means that instead of being 100000 times smaller it’s 100000^2 times smaller. Anyway, I scale the mass of the earth down by that amount because the distance is dividing.

Instead of using the rigidbody mass of the earth i made a separate value in the script attached to it because the rigidbody doesn’t allow such large values. anyway, I use the formula and the mass of the earth scaled down, the real value of G, the distance scaled down and I don’t use m in the equation because since it mass doesn’t affect the gravitational attraction on the spacecraft i just set the spacecraft’s rigidbody mass to 1 that way when it applies the force i calculated it won’t matter that i didn’t use mass of the spacecraft.

Also, to keep the ISS in orbit, i give it it’s real life velocity scaled down by the same amount> 0.0766

``````    void Attract(GameObject bodyToAttract)
{
Rigidbody rbToAttract = bodyToAttract.GetComponent<Rigidbody>();

direction = transform.position - rbToAttract.position;
distance = direction.magnitude;

if (distance == 0)
return;

double forceMagnitude = G * (mass / Mathf.Pow(distance, 2));

force = direction.normalized * float.Parse(forceMagnitude.ToString());
}
``````

This is the part of the code that deals with the actual attracting.
Anyway, the problem lies in that, despite me going over this a thousand times and spending hours trying to figure it out, it just doesn’t work, the spacecraft just goes almost straight against the planet. It maintains of course it’s initial velocity, but the force just seems way too strong, and it shouldn’t be. I have tried using different ForceMode s but nothing works. I don’t know if it’s a problem with my math or with my code.

I may have explained this poorly so please ask any question you have.

Any help would be infinitely appreciated. This is quite important.