In my game there is a building system where players can build entire buildings and create something inside of them. The only issue with this is sometimes terrain grass from the map can clip into the floors.
I’m guessing the solution would to change the material of the terrain to leafy grass, but these buildings can be placed anywhere. So, how do I temporarily remove the grass from the area under the building and put it back later?
Basically, you’ll have to determine the area where there should be no grass, then use the :ReplaceMaterial() function to change the material. This can be called multiple times to undo when needed.
Thank you, but I’m not certain that this is the exact solution. The issue comes when the building would be destroyed and the grass would need to be replaced. Replacing any leafy grass under the building with normal grass might change some leafy grass that isn’t supposed to be normal grass.
Possibly some sort of way to store that chunk of the terrain would work? The map is static so a system such as this might work:
Building is placed
Copy the terrain region below and store it
Change the material underneath from any grass to leafy grass
When the building is destroyed replace the terrain underneath with the saved terrain chunk
As a side note, this would account for any uneven terrain as well and would be the most accurate way to restore the map.
:CopyRegion() will allow you to copy a region, you will have to try it out and see which works best for you. :FillBlock() might also work, as you could copy the block size, and just change the Y position below the block where the terrain is.