I am in the process of developing a 2D digging game for mobile. I need an efficient method to dig tunnels through the levels (Similar to the game play in Death Worm), and build colliders around the tunnels.

How would I go about it?


You should look into isosurfaces (mainly marching squares)

The idea is very simple, you have points in a 2d space, each of them has a value between 0 and 1 attached to them.

Whenever the terrain changes you need to run the points through the marching squares algorithm and that gives you a mesh around the contour of the points with a value higher than a certain threshold.

If you want to dig a hole in the mesh, then you can get every point in a certain radius from the center of the bew hole and decrease their value so it will be under the thresholdof the algorithm.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.