Barely Breathing received a new procedural puddle system that uses raycasts, BFS, and Marching Cubes to react to walls and uneven ground.
When you drop a bottle or a glass of water in the game, it creates a puddle wherever it lands.
The previous version used a simple circular mesh for the puddle. It worked, but the water could float over empty space and even spread through walls.
This new version solves both problems by generating the puddle as it spreads across the environment.
The new puddle spreads one point at a time using a modified Breadth-First Search (BFS) algorithm.
A regular BFS creates a diamond-shaped pattern, so they changed the order in which new points are added. Points closer to the center spread first, giving the puddle a more circular shape.
As the puddle grows, raycasts keep it from spreading through walls and make sure every new point lands on the ground.
At this point, the puddle still looks like a group of separate points, so the developers use the Marching Cubes algorithm to merge them into a single surface.
It builds a smooth mesh around those points, and the parts that fall onto different surfaces stay as separate puddles.
The previous puddle was not just something the developers wanted to improve. They also received feedback from players.
The idea came from spilling a glass of water and watching how the puddle spread in real life. The developers wanted the game to behave the same way.
If you want to check out the game, or know more about the developers, the links will be right below.
Interested in learning more?
If you’re interested in the technical side of Unity? The
Unity Dev Bundle brings together
six books covering shaders, math, procedural shapes, editor tools, and character customization.