I need help to make and object follow my mouse but snap to a custom 64x pixels grid

I’m making a building system for my game (No [Redacted] Sherlock) And i need a grid based movement that will snap to my game with perfect snapping that goes with a 64 space. I know a lot of you are lazy and find other games to help but if you do i don’t want to se “Land Builder Test” I tried and it does not work for my game because it only snaps to 32 plus it don’t even snap to the game which is very bad so don’t even use that game link please.

I have a game here that could help: https://flowlab.io/game/view/1514550

1 Like

But how would i use this to work for a 2x2 tiled block

like do you want it where it moves by 2 tiles or just a 2x2 object that moves by 1 tile

I think if you mess around with the math (specifically the rounding) inside the placer object you could figure something out

Divide the position by 64, round it, and then multiply it by 64.

You could just make a new expression, since it rounds to go between expressions,
but you could also use the Math.round() like in @Baconcat008’s example.


I want a 2x2 object to move by 2 tiles that is perfectly aligned with the game

Wow geez thanks @JR_01 dont know how long i was trying to figure this out, and it even aligns perfectly with the game

1 Like

No problem

If it seems off, try the Math.round() in the same expression. When numbers leave the expressions, they’re actually rounded down instead of up, so Math.round() is another alternative to get the values.

That’s what i did i believe and it works really good :+1:

1 Like

Yeah this is what a used Math.round(A / 64) * 64

1 Like