- Home /
Two objects sticking(magnetic) together, if one object is dragged close enough
Hello Guys, I'm making a bit of a puzzle game. It is about placing cubes that are held together (by joints) in a order so it becomes a big cube.
Stats: 27 Cubes 1x1x1 each cube is connected with a configurable joint (so no kinematic), because there are axes the cubes should not move on.
Example: You have 5 cubes in an L shape.
3 4 5
2
1
The joints between cube 1, cube 2 and cube 3 are only rotatable on the z axis, while the joint between cube 3 and cube 4 can only rotate on the x axis and so on.
This works like a chram, but the problem I encounter is a bit frustrating. I can drag and drop any cube, but since they are all connected it's hard to put them were they should be (to create the big cube). So I need something like a magnet. If I drag one cube close enough to another one the sides of both cubes should snap together, but not fixed. If I drag the cube again a bit away, the connection between these two cubes should break (like a friggin magnet). I searched for it, but somehow I couldn't find the right answer.
Your answer