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. P.S. I’m using Javascript.