Gravity simulation not accurate. Can't understand why


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)

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

        force = direction.normalized * float.Parse(forceMagnitude.ToString());
        rbToAttract.AddForce(force, ForceMode.Force);

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.

Thanks in advance

I have solved the issue. It turned out to be rather simple: I had scaled all the distances down by 100000, so 1 unit was 100000 meters and I had adjusted the mass by the same proportion to make up for that, as I wrote in my question. However, the force appeared to be out of proportion despite my rigorous examination of all the scaling I has done. And finally I found of course that I have to divide the force magnitude by 100000 as well, because 1 N = 1 kg⋅m⋅s^−2 So if I have made 1 unity meter into 100000 real meters, I also have to apply this scaling here.

Thanks for your help @JVene !