HOTO snap to grid building TD style?
Let’s take for example - tower is 2x2 squares. How snap to grid tower preview after selecting tower type and before build with left click in TD style game?
Terrible solution i think is invisible squares, that detect mouse hovering, but i really don’t like this way.
I’m pretty sure the formula you’re looking for is something like this :
Tower X position = floor( Mouse X position projected on landscape / grid cell size X)
Tower Y position = floor( Mouse Y position projected on landscape / grid cell size Y)
I hope it helps.
yeah ty, also found good tips about getting mouse cursor on landscape
Get Hit Result under Cursor
convert mouse location to world space