Block Water 2D – Getting My Feet Wet

While both Block Lighting Engine 2D and Terrainify 2D are doing fine, I couldn’t resist starting development on my third asset. This asset will be Block Water 2D and it’ll deal with grid-based water flow and the first test run looks pretty promising.

So, why isn’t this an asset yet? Well, it’s actually unfinished. There is still a problem in its functionality I want to fix. This problem is something I like to call the u-shape problem and it is actually nothing new. Terraria’s water system for example suffers the same problem. The problem arises whenever a body of water forms with a partial vertical separation between two or more areas of that body.

When you look at the picture above, you expect both sides of that small body of water to even out, because they are connected at the bottom. The algorithm I created, however, doesn’t take into account the possibility for water to rise. This isn’t really that hard to add, but the actual problem would be how far should that side rise? In reality, this happens because of water pressure. The higher side exerts a greater downward force because of gravity and because of this, water is pushed from one side to the other. It always tries to find a balance.

It’s not that big of a deal. Most systems I’ve seen leave this in because especially in a game world, is this really a must-have? If you have a game based entirely on the behavior of water for core mechanics, then it makes sense. Imagine using some kind of u-elevator as a boat lift for example. But for a 2D survival world where water is only a smaller part of the bigger picture? Not really. I understand why Terraria would leave this in.

Weighing both sides, I decided to give it a try to fix it. It’ll become an asset and I want to satisfy as many use cases as I can and I think this will be an interesting challenge to tackle. The most obvious tactic would be to go for a pressure system where blocks keep track of how much pressure they have.

Even if I manage to find an optimized solution, I still have a lot of polish to do, not to mention adding a user interface for people to customize water settings. But that is something for another day. Right now I am enjoying the feedback from the social media communities and I’ll be back with an update once I have more to tell.