I’ve made a placement system for placing shelters down on terrain. Currently when you place a shelter down it makes flat terrain underneath it by filling in a part with terrain. Issues happen when you remove your shelter - the land underneath is still flat. How would I make it so when you remove your shelter the terrain underneath it reverts to what it was before you placed your shelter?
1 Like
I would go about it like this:
- When you place a shelter, use CopyRegion to make a copy of the chunk of terrain underneath the shelter. Store the
TerrainRegionyou get somewhere with the data for the shelter. - When you remove the shelter, use PasteRegion to revert the change.
Things get more complicated if:
-
Two shelters can have overlapping flat regions.
- In the case where shelter B’s flat region intersections shelter A’s, you’ll need to revert the terrain under A before calling
CopyRegionon B’s terrain, then you can flatten both again.
- In the case where shelter B’s flat region intersections shelter A’s, you’ll need to revert the terrain under A before calling
-
You need to store the
TerrainRegionin a DataStore- This is probably fine, but I’m not 100% sure that TerrainRegions can be stored in DataStores. If they can’t, you would need to implement your own version of CopyRegion/PasteRegion using
ReadVoxels/WriteVoxels.
- This is probably fine, but I’m not 100% sure that TerrainRegions can be stored in DataStores. If they can’t, you would need to implement your own version of CopyRegion/PasteRegion using
2 Likes
Thanks for your reply! The game has a feature where you cant overlap each others shelters! When you place your shelter down a 28 studs area around the shelter is also yours!
Makes your life easier then ![]()
1 Like