예제 #1
0
    // Attract another gravitational body

    public void Attract(SpaceBodies body)

    {
        Vector3 r = this.bodyTransform.position - body.bodyTransform.position;



        // Newton's law of gravitation

        Vector3 force = r * G * body.rb.mass * this.rb.mass / Mathf.Pow(r.magnitude, 3);

        body.rb.AddForce(force);
    }
예제 #2
0
    private void FindNumberOfOrbitParents()

    {
        SpaceBodies target = OrbitTarget;

        while (target != null)

        {
            numOrbitParents++;

            target = target.OrbitTarget;
        }
    }