Magnetic pieces being attached to each other and moving together ???
Hello ladies and gentlemen. I'm trying to make a magnet system where there are pieces with two colors, blue and red. Opposite colors pull each other and different colors push each other back. Exactly like a magnet. I'm doing Overlap.sphere on each piece to check pieces that are close and then check their color, after this I just add a normal movement function (I tried "addforce", "transform.translate", "moveposition"). It works just fine, but my problem is when two different colors "connect"/"attach" to each other AND if other piece passes by and attracts one of them, they both need to move (Ex: There are two pieces Red and Blue connected, another blue piece comes by and it's attracted by the red piece -> The entire connection(The initial blue and red pieces) are pulled to the new blue piece). I don't need an entire pre-made script, but if you do it the better. I just need a light, some guidance. With the system and checking I'm doing, it's really hard to make it work. I'm studying the use of Joints but it is still very clunky. Any tips?
Your answer
![](https://koobas.hobune.stream/wayback/20220613024830im_/https://answers.unity.com/themes/thub/images/avi.jpg)