Hello, i been trying to implement grid based building system into my project. Specifically i am looking for a way where player can pick a spot on a grid with mouse and then hold and drag and when released it builds a square or rectangle structure so it floor mesh on inside and walls on outside. I did managed to figure out with help of guides how to make a grid building system where player picks a building and clicks on grid where the building mesh spawns while being snaped to the grid but i cant seem to find any resources on the drag build functionality. So i would very much appreciate if someone could point me to some resources covering this topic.
You could set collision boxes for each grid and detect collisions for the object, but then that would create conflicts as 4 collisions would be triggered at the same time. To detect which grid is the object closer to, you can cast a line trace from the object straight down to the ground, detect the grid that it returns as the hit result and locate the object there when you release the dragging input key.