Download

Dragging out walls

I’m just wondering if anyone has any ideas on how I would go about allowing the player to place and drag out a wall. If you think of a game like The Sims for example, the player can click on the ground and then move their mouse to drag out a wall. Clicking a second time finishes the wall. I would like the wall to conform to a grid so it snaps to grid intervals as you drag.

I’ve looked into using instanced static meshes, but from what I understand, they don’t have any collision on them. Once the player has placed the wall, I would like the player to be able to select it again by clicking on it, so they can remove it or extend it further for example. I did read someone saying that you can manually create collision for an instanced static mesh, so maybe that is an option.

I would like to make the wall building system a bit smart too so that the player can drag walls to create corners and intersections too.

I would like to get other people’s ideas on how they might do something like this before I start working on it. I plan on doing it in BP for now, but am happy to work in C++ if needed.

The grid snap position closest to the initial mouse left click for placement would be your start of the wall, then all you do is take the current mouse position and get the grid snap closest to that on the current frame and just create instances of your wall to fill in the gaps between those 2 points.

If you do it all in a BP Actor you can then detect when the Actor is clicked on again, taking either end piece of the wall closest to the mouse click location and then that just becomes the start of a new wall again.

Making it “smart” would be a little more tricky, though you could just make it that the player “draws” the wall on the grids, so as the mouse moves over a grid snap, it places a new wall piece in that position, that would allow you to easily create corner sections and all other sorts of shapes.

Thanks for the comments. Your logic is along the same lines as what I was thinking. I will start experimenting with this and post any results/questions as I go. If anyone else has any other ideas to explorer please let me know.