How can I access all game objects connected in a cluster by fixedjoints?

I am new to Unity, but not new to game development. I have been trying for some time now to set up a sort of clustering system for some objects in my game.

Basically, I have multiple moving objects in my world. They will all be of the same object type and will be running the same base script. When they hit one another, they stick to one another and I already have fixed joints being created to hold the objects together. My question is:

How can I, from the script of one object, access each of the other objects which are connected to one another via fixed joints? It seems like an easy problem to solve, but the tricky part is that object1 could be connected to object2, and object2 could be connected to object3 and object4. I need to be able to access all four objects, in code, from any one of the objects. For instance, if one is destroyed, I want to inherently destroy the other three.

Any help is much appreciated. :slight_smile: P.S. I’m using Javascript.

I would suggesting finding objects of type x.

function OnMouseDown () {
    var hinges : HingeJoint[] = FindObjectsOfType(HingeJoint) as HingeJoint[];
    for (var hinge : HingeJoint in hinges) {
        if ( hingeConnected ){
            code......
        }
    }
}

Obviously, Joints or w/e needs to be of type (whatever you are wanting), and hingeConnected depends on your way of detecting this… I don’t have your code, so, you will have to do that part .