A snapping puzzle to the grid


#1

Hey,

I know there are few old topics on the forum about grid, but they are old and have old project examples format (gdg). I’ve tried few things from those topics, but I can’t handle…

I just want to make most simple puzzle game. For now I have pieces on one part of the screen and board for which I can put on the puzzles. The rest of screen has collider which makes the pieces back to their original position when I drop them there. It’s fine, but I the thing is, my puzzles has no grid and I can put them on board chaotic, while I need them to be snapped in order :slight_smile:
Any ideas how to do this in some simple way? :slight_smile:

I use for testing assets from “pieces” example :slight_smile:


#2

You could do your grid as pieces put together instead of a background image
each grid piece a Sprite then when you release the puzzle piece check if it is over a grid piece and if it is center it.


#3

yes, I thought about something like that :slight_smile: But could you tell me which events and actions use to achieve that effect? I’m not good in variables and numbers :sweat_smile:


#4

i guess your objects have draggable behavior. You have is dragging event, I don’t have a computer at the moment bit look for this event, then you need a variable to know which object is being dragged. When you release mouse get X and Y coordinates of mouse.
Is a bit trickky, i started the code but left incomplete before finishing.


#5

Thanks, I’ll try to do something but I’m not sure if I can handle :slight_smile:


#6

will rescue my unfinished Code i think it will help