I'm creating a grid of tiles (the size of the grid and tile can change), and a randomly sized rectangle.
The rectangle is always some multiplication of the tile size - for example: 3 tiles X 4 tiles etc...
The rectangle is draggable, and I need it to behave in the following way:
1. Always stay within the grid boundaries
2. Move along the grid lines
- I've sorta managed to do number 1, although there's a very jittery behavior near the edges - if anyone can help with that it would be GREAT!
- I ripped nearly all my not-so-thick hair trying futilely to get the second behavior to work - no matter what I try, I only manage to get the rectangle to be dragged by tile-sized increments, but it is never aligned with the grid itself... and worse, this misalignment changes as one changes the screen size!
PLEASE - help me keep what little hair I have left...
The project file