Simulating gravitational attraction between bodies - follow up I've decided to revisit a chunk of code I wrote a while back, and see what I could do to make some changes. As a result, I know have slow, but working piece of code which is able to simulate gravitational attractions between \$n\$ amount of bodies. Like usual, I'm using the formula described in Newton's Law of Gravitation, as seen below:

$$F=G\frac{m_1m_2}{r^2}$$

using UnityEngine;

/// &lt;summary&gt;
/// Gravity component.
/// &lt;/summary&gt;
[RequireComponent(typeof(Rigidbody))]
public class GravityComponent : MonoBehaviour 
{
    public float gravityConstant = 1;
    public Vector3 startingForce;

    /// &lt;summary&gt;
    /// Applies attraction to the object.
    /// &lt;/summary&gt;
    public void ApplyAttraction()
    {
        foreach(GameObject body in GameObject.FindGameObjectsWithTag("body"))
        {
            Vector3 force = body.transform.position - this.transform.position;
            float attraction = 
                  (this.gravityConstant * this.rigidbody.mass * body.rigidbody.mass)
                / (Mathf.Pow(force.magnitude, 2));
            this.rigidbody.AddForce(force * attraction);
        }
    }

    public void Start()
    { this.rigidbody.AddForce(this.startingForce); }

    public void FixedUpdate()
    { this.ApplyAttraction(); }
}


Ideally, I'd like to know the following things:


Can the performance be better? Right now it runs at an okay speed with about 10 bodies on my laptop, but once it starts getting past that, it begins to slow down rather drastically.
Am I doing anything wrong Unity3d-wise?
Is my code written in an idiomatic manner?
Anything else?


For anyone who might be interested, you can find the repository on GitHub here.
Disclaimer: I have no idea about Unity3D.  

that being said, if there is no reason regarding Unity3D to keep this public


public float gravityConstant = 1;
public Vector3 startingForce;  



then make it private.  



I don't like this method writing style  


public void Start()
{ this.rigidbody.AddForce(this.startingForce); }

public void FixedUpdate()
{ this.ApplyAttraction(); }  



IMO if something doesn't fit good into the same line, one should use 4 lines of code.  



The only obvious place where you can gain some performance boost would be at calculating the attraction. 


float attraction = 
              (this.gravityConstant * this.rigidbody.mass * body.rigidbody.mass)
            / (Mathf.Pow(force.magnitude, 2));  



instead of calling Mathf.Pow(force.magnitude, 2) a simple force.magnitude * force.magnitude will be faster, because there won't be done any checks if e.g the power contains a valid value.