Getting a variable from a script without knowing its name

I’m trying to let plants dynamically grow, and one issue I’m running into is making sure they don’t overlap.
The plants are made up of circles that spawn new circles around them every now and then.

What I’m trying to do is, whenever a circle tries to spawn a new circle, it will choose a spot next to it, and check if any circles will overlap with it, by comparing the magnitude of the vector between the chosen spot and the other circle, with the sum of the radii of the circle that is being spawned, and the circle that is being checked.

The problem is, the radii vary between circles, and do not match with the scale in the transform component. (EG a circles with a scale of 1 have a width of about 0.09 in positional units.

So the solution I’m trying to get at, is giving every behaviour script a public variable called radius, and have a circle pull that variable from the script when its checking for overlap.

The problem here is that every circle will have a different behaviour script based on which part of the plant it is (trunk, branch, leaf etc.). This means I do not know the name of the script I’m trying to pull the radius variable from.

Does anyone know a solution to this? Am I even looking at this the right way?
Thanks in advance!

You can make a script which is responsible for growing all plants. When it creates a plant, it would store information about it’s position and radius in a list. When the script makes another plant, it would check to make sure the new plant’s position doesn’t overlap the existing plant, and then add that new plant’s position and radius to the list. Every time you want to add another plant, this script will first check against the saved position and radius of all the existing plants.

Why not make your life easier and make a single behaviour script that contains all cases for trunks, branches, etc. Then create tags (branch, leaf, stalk, trunk, root, etc) and assign them to each game object depending on what it will be.

Now, from within your single main behaviour script, you can choose which behaviour to occur depending on the tag of the object containing it. A little like this:

void Update()
{
        if (this.CompareTag("Leaf"))
        {
            // do leaf stuff
        }

        if (this.CompareTag("Root"))
        {
            // do root stuff
        }
}