# Need input on a terrain "stability" system

This topic is 2560 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

My game is a 2d platformer with blocky terrain ala Terraria. I'm working on a system that calculates how stable a given block is. If it becomes unstable enough, it collapses. To keep things simple I have two values which are compared to decide if a block is unstable: pressure exerted on a block and the block's strength. Pressure is applied by things above the block (liquids, monsters, the player, etc). The strength is calculated by adding a base value for the block (depending on what type it is; dirt is weaker than stone) and a value for each block to the left and right of it (simulating the pressure being distributed). One thing to note is that if there's a solid block below the one that's currently being calculated, then it can not collapse.

Now to my question: what affect should should solid blocks that are above the one currently being calculated have? Should a block above reduce the pressure placed on the block below or increase it? The first inkling I have is to make it reduce the pressure since it might help redistribute it, but I'm not so sure. My goal is to keep this system as realistic and simple as possible, so if you have any other suggestions please feel free to share!

##### Share on other sites
Should a block above reduce the pressure placed on the block below or increase it? The first inkling I have is to make it reduce the pressure since it might help redistribute it, but I'm not so sure.
Managing those kind of things in a realistic way involves FEM-like approaches and there is quite some research going into that for static and dynamic stress. If you ask a civil engineer they will be able to grossly explain you the notions involved.
Ok, let's make it simpler.
It is indeed possible to figure out, for example, the max weight of a truck going over a pipe buried at bcm depth without cracking it. This is surprisingly simple and involves casting the force "down" while distributing it, where the amount of distribution is a function of material. So, if you want to make it realistic, I'd suggest to start looking at this direction.

Please note however than while this model would be theoretically and practically accurate to model a stand-alone block it has two issues
1. It models a block's resistance, not its "need to fall down"
2. This is not a local property, whole clusters might need to fall down, while their internal blocks stay in place.

I think you might work it out by using a physics library and breakable constraints.

Materials in the real world can indeed collapse even when having a solid base. I guess some terminology cleanup is needed here.
A pillar will never collapse (in the sense of falling down) by itself but it can indeed collapse (in the sense of being crushed) as a result of too much load, causing everything above to collapse (in the sense of falling down). I take you're really only interested in falling down behavior?

Just to be sure we're on the correct line of thinking.

##### Share on other sites

Now to my question: what affect should should solid blocks that are above the one currently being calculated have? Should a block above reduce the pressure placed on the block below or increase it? The first inkling I have is to make it reduce the pressure since it might help redistribute it, but I'm not so sure. My goal is to keep this system as realistic and simple as possible, so if you have any other suggestions please feel free to share!

I would ignore it. If you're showing the player a side view of a cave, that block above the block in question should be supported by the foreground and background. You might have to consider it if blocks fall, but it sounds like you're talking about static blocks.

##### Share on other sites
Glad someone even understood what I was rambling on about. The goal is to break the real world phenomenon of pressure into its simplest form, but doing so makes the conversation really abstract

I should have explained why exactly I thought this might be the case. Apologies in advance for any terminology I mess up. In my very limited understanding of these things, I thought that a block might redistribute the weight to blocks around it, instead of all the pressure being placed on a block immediately underneath it. In the example below the Xs represent solid blocks and the Os represent open spaces.

O O O
X X X
O X O

Because of gravity more pressure will be exerted on the bottom block, but wouldn't some of it be relieved because the middle block has two blocks supporting it?

I'm hoping to keep this system as local as possible. The purpose of it is to give the environment some life, rather than everything being made up of stagnant blocks. An example of what might happen as a result of this system is that a large room fills with water and exerts a certain amount of pressure on the floor of the room, depending on how much water is above it. A floor that is five layers thick would be able to support a larger amount of pressure before cracking than one that is a single layer thick. If the floor is a single layer thick then parts of it will begin to weaken until a piece finally breaks and falls to the ground below (this is why a block can not collapse if there's another block underneath it; only the bottom-most block will collapse). This will allow the water to begin draining out, but because a piece of the floor is missing the blocks that are right next to the missing piece are weaker, resulting in them collapsing if there's still enough pressure being exerted on them by the water above.

In the interest of simplicity it cannot behave in a completely realistic way (which a physics library would allow), so a small set of rules is what I have to work with. The "water filling a room" example I gave above sparked an idea: perhaps a situation such as the first example below would increase the pressure exerted on a block, while the second example would make no change to it and the third would reduce the pressure.

O O O
O X O
O X O

O O O
X X O
O X O

O O O
X X X
O X O

EDIT: Just saw your post Kobo. I'm hoping to move away from static blocks by using a system like this. The blocks surrounding any given block are what affect it; I don't take into consideration that they would realistically be supported by the fore/background.

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633767
• Total Posts
3013734
×