// 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); }
private void FindNumberOfOrbitParents() { SpaceBodies target = OrbitTarget; while (target != null) { numOrbitParents++; target = target.OrbitTarget; } }