public VirtualBody(CelestialObject body) { position = body.transform.position; velocity = body.GetVelocity(); mass = body.GetMass(); pathColor = body.gameObject.GetComponent <Renderer>().sharedMaterial.color; }
protected static Vector2 GetForceInteraction(CelestialObject obj1, CelestialObject obj2) { var r = obj2.GetPosition() - obj1.GetPosition(); var m1 = (float)obj1.GetMass(); var m2 = (float)obj2.GetMass(); if (r.magnitude < 1) { r = r.normalized; } return(r.normalized * ((m1 * m2) / (float)Math.Pow(r.magnitude, 2))); }