How to attach a sphere to another sphere within a certain radius?

Hi, I am trying to implement a chemistry builder game and have a red sphere and white sphere corresponding to oxygen and hydrogen atoms. Currently, the user is able to drag these atoms around on in the world. The behavior that I’m trying to implement now is that when the user drags a hydrogen atom within some radius of the oxygen atom, I want those two GameObjects to “connect” or “stick” together and now I can drag that compound around. How do I go about achieving this behavior?

You could add a trigger collider to the atoms and add a script to them with OnTriggerEnter function. OnTriggerEnter should handle connections. Personally I would create another object called Molecule or something and any atoms that “connect” to each other would actually become a child of the molecule. If you select an atom that is connected to the molecule, it would instead select the molecule so dragging around would drag the whole thing.