Modifying a mesh to simulate a digging effect

Hey, so pretty new to unity and game development in general but basically what i am trying to achieve is a digging effect. As an example of what I’m after, assume a player is standing on a cube and the character can hit the cube with an object and a after a digging animation and duration a deformation of the cube’s mesh will occur at that hit point instantaneously. if the player was to keep digging away eventually the cube would be destroyed. My world is done in a low poly style so the target mesh i want to dig is made up of noticeable sized polygons.

Sort of just after a direction i should take with this? Perhaps using unity’s mesh class and displacing the vertices around the hit point? An idea i had would be to edit the vertices based on how close they are to an origin similar to blender’s proportional editing but I’m not sure about how to go about this. Is there a more appropriate way to do this?

You can try playing with the values and see which give the mesh a deformed look and write a quick script that changes the mesh based on how many times the digging affected it.

So i managed to produce a deformed look through adding forces to the vertices proportional to the distance from a raycast from the camera to where the player is looking. The next step id like to go from here is, the deformation is great, i can sink in the ground creating a digging effect, but continued digging would just give the polygons a super stretched look so does anyone know a way in which i can say, add new triangles to the deformation so it stays proportional and there being a limit as to how far the triangles can stretch before a new one is added?

look up “marching squares” :slight_smile: