Need help checking distance between multiple objects,How do I check the distance between multiple objects at one time?

Hey! Im trying to create a random solar system and im having this issue with the planets spawning inside of eachother occasionally. Any help would be appreciated.

 GameObject[] planetBodys;
float distBetweenPlanets;
public float minDist;
public PlanetCreator pCreator;

private void Start()
{
    
}

void Update()
{
    planetBodys = GameObject.FindGameObjectsWithTag("PlanetBody");

    foreach (GameObject planet in planetBodys)
    {
        distBetweenPlanets = Vector3.Distance(transform.position, planet.transform.position); 
    }

    Debug.Log(distBetweenPlanets);

    if(distBetweenPlanets != 0)
    {
        if(distBetweenPlanets < minDist)
        {
            transform.position = pCreator.GeneratedPosition();
            Debug.Log("Moved!");
        }
    }
}

i tried this and also this

public SphereCollider trigger;

public Transform planet;
public PlanetCreator pCreator;

void OnTriggerStay(Collider other)
{
    if(other.gameObject.tag == "PlanetBody")
    {
        planet.transform.position = pCreator.GeneratedPosition();
        print("Collision Detected!");
    }
}

private void Update()
{
    trigger.isTrigger = true;
    trigger.radius = 500;

    planet = transform.parent;
    pCreator = planet.GetComponent<PlanetCreator>();
}

I couldn’t get either to work.

,Hey! Im creating a procedural star system and I need some help figuring out how I can prevent these planet meshs from spawning inside of each other.

GameObject[] planetBodys;
float distBetweenPlanets;
public float minDist;
public PlanetCreator pCreator;

private void Start()
{
    
}

void Update()
{
    planetBodys = GameObject.FindGameObjectsWithTag("PlanetBody");

    foreach (GameObject planet in planetBodys)
    {
        distBetweenPlanets = Vector3.Distance(transform.position, planet.transform.position); 
    }

    Debug.Log(distBetweenPlanets);

    if(distBetweenPlanets != 0)
    {
        if(distBetweenPlanets < minDist)
        {
            transform.position = pCreator.GeneratedPosition();
            Debug.Log("Moved!");
        }
    }
}

I tried to do this but this doesn’t work. Any help or suggestions would be much apricated. I also tried to use a trigger sphere but i couldnt get that to work either

Didn’t mean to double post that, but here is an example of whats going on