Jigsaw Puzzle mechanism

71 Views Asked by At

Could anyone teach me how to make a jigsaw in unity with a mechanic like this https://m.youtube.com/watch?t=9&v=A957VVS299o&feature=youtu.be

I know how to drag and drop but with that weird grid mechanism, it realy takes a toll in my head

1

There are 1 best solutions below

0
Geeky Quentin On

I worked on a similar type of mechanism for a group project, I did it this way, assuming the tetris blocks in the game are all cubes of size 1 unit. For different shapes, the conditions might be different

  1. Every slot in the grid and the tetris shape must have a box collider, which is set to trigger.
  2. When you click and drag on the shape, detect it with OnTriggerEnter2D, and set the position of the block to the position of the cursor as long as it keeps dragging it.
  3. And while releasing on the grid, check to which slot in the grid this shape is closest, and set its position to the shape, which is the snap functionality.