How can I connect a Game Object with another Game Objetct ?

Thank you for your watching.

I am trying to make a gear, and I want to combine gears.

To be accurate, I am trying to make NOR-Gate.

Blue bar is a Input bar. And this is “OR-Gate”. we push from right side. following image is pushed state.
(It may appear that there is only one input area. But, actually, there are two input areas. Each input area is separated by a location.)

Red bar is a output bar. And green gear is a “NOT-Gate”.

Then, I want to connect a Cube/Cylinder with another Cube/Cylinder, and rotate a gear.

But it does not work. The cubes fly away(I checked “use gravity”).

So I have a question.

How can I connect a Game Object with another Game Objetct ?

Thank you.

You pick specific spots of the object where You want another object to connect, create Boolean conditions to make before connecting them by making their transform equal the transform of corresponding connection spot. Then make the connected prefab a child of the other prefab using

Object1.transform.parent = object2.transform