Looking for a "Digger" like digging method to cut through ground

Hi all,

I’m new to unity and I began working on a game that is supposed to work eventually on iOS/Android platforms.

In my game I need a “Digger” like method for digging. I got a little object for the player that can dig through the ground.
My game is supposed to be a 2D game and at the moment I’m using an orthographic camera.

I thought that maybe I should use a high poly plane that I would somehow cut through it by joining/removing polygons, or maybe use a some kind of a mask that would be created by my digging player.

But I got no idea how to begin with it, and if it would be efficient enough for the mobile platforms.

In short it would be nice to get an efficient and simple solution, but at my current situation anything would do!



This is not the easiest thing to do with polygons. You'd have to implement your own boolean logic. But it's not impossible, read up on the mesh class to begin with then have a look at triangulation. You'd also have to make some serious calculations for the collisions where working with concave mesh colliders isn't the easiest.

Another (easier) approach to this is to implement your own collision detection against an image alpha where the player only can move within the given alpha. The alpha cuts out the non-needed pieces of the mesh. Here you could make use of the Texture2D.SetPixels.

There's probably a third solution I can't think of right now, maybe someone else can give you a heads up!

Thank you very much for your thorough answer!

I think I would go with your second solution. I’m not a big expert with unity, but my common sense tells me it would probably be easier than editing a 3D object, and maybe even more CPU efficient.

I’ll try and hop right into action, but I already sense I’m not really familliar with all of the “textures terminology” so maybe I should begin with it first.

Any chance you know of any good place to start with? Or would I just be better off with Unity’s Documentation?


Hey @Orchestrator ,
Did you find any solution for this please ?