I have a click-and-drag wall builder but am in need of help getting the edges smoothed out and ideas on how to handle overlapping pieces. I will attach the place file for you to use - full code (it’s in the StarterPlayerScripts > gameCode > Classes > WallRender) Let me explain in two-step below.
Smoothening with Wedge Parts
The YouTube video below shows how it currently works and that non-straight segments are jagged. How can I (you don’t have to modify my code or look at it, but even linear ideas are welcome) properly insert a WedgePart into those corners rotated correctly?
What sort of algorithm would you propose I use to determine when a wall gets placed next to it - or when the new wall is placed next to an existing wall - so I can then remove the original accent pieces that are on the edges?
Solved the first problem (smoothening sharp corners with wedge parts). Shown below. Code solution also shown.
I check if the next wall piece being drag-built is on the same axis as the previous one (comparing the previous wall’s X and Z). Then, if they are both different, I get the direction to the next piece.
The red is the direction. Then I apply 2D vector rotation to get the yellow lines (which are 90 degrees from the original base). I place the wedges at those positions. I custom-create the rotation matrix to make sure the wedge faces the right place.
you could use GetTouchingParts() and see if anything overlaps but I think that using CollectionService is highly bad for this case scenario so better stick with GetTouchingParts, returns an Array of Touching Parts