Obstructing terrain grass temporarily

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.

image

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?

I don’t think it’s possible to do that :pensive:

I’m only looking to obstruct the grass in a specific area, not disable it entirely:

You can use this:

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:

  1. Building is placed
  2. Copy the terrain region below and store it
  3. Change the material underneath from any grass to leafy grass
  4. 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.

I mean idk, storing terrain in a Region could be possible’ish? Might be a bit hacky to get around though

I’m looking around though

I have looked at these functions before, I’m mainly trying to get the process figured out:

Do you think there would be any edge cases where this wouldn’t work?

I don’t believe so, but you will need to try them out for yourself to see what works for your game.

1 Like