Need help for some idea

Let’s say there are two cubes that are physically attracted to each other (I know, it sounds dirty :D) -> 2x[ ] When you bring them close enough, they push them selves together (like magnets) and stick really hard (like it would be one object now) -> [ | ]. Also they need to stick precisely, so a new solid cuboid is formed from both. Performance is important, as there can be a lot’s of cubes sticking.

If anybody could kick start me in the right direction, that would be very nice. I guess I will need to jump into some physics module, but no idea where to start :frowning:

You can set direction of the gravity in the RigidBody using setGravity(v:Vec4). It will only affect that particular object, and not all objects.

Once two cubes are within a certain distance from each other you can set the direction+strength of the gravity toward the other cube, so they move towards each other.

On collision, you can disable the gravity and use a Tween to move the cubes into place perfectly next to each other. Once tween has completed, you can replace the two cubes by deleting them and spawning a single cube in the same size as the two cubes. Alternatively you can delete one of the cubes and change the scale of the remaining cube in case you are only using simple colored materials without UV-mapping etc.

Looking forward to seeing a video of the results! Good luck! :slight_smile:

Many Thanks. Just one detail. The sticked together cubes, can be tear apart with very strong force. So… will see about that replacing scenario. Probably will be needed because of performance?.