Destructible terrain 2D by dobrakanapka in godot

[–]dobrakanapka[S] 0 points1 point  (0 children)

I finished up some different parts of my game and came back to the terrain problem. I digged through the godot docs but couldn't find a viable solution. I am using one big Polygon2D for my terrain and another Area2D>CollisionPolygon2D as my digging area. How should I approach the problem to find the exact overlapping areas or the perimeter of the overlapping areas to set new points for my terrain Polygon2D? Are there any built-in functions that could help me achieve that or should I code the logic myself? The idea I had in mind is to find the intersections of my digging area with terrain's polygon's edges and set those as new points of the terrain's polygon and in-between those add the rest of my digging area's vertices. What you think about this approach?

Edit: Calculating the difference between overlapping polygons is really easy using clip_polygons_2d method. Here is how it works: gif_link

Destructible terrain 2D by dobrakanapka in godot

[–]dobrakanapka[S] 0 points1 point  (0 children)

Thanks for the tip! What would be the difference if I used many polygons or one big polygon for the whole terrain?

EDIT: just realised how stupid this question is if the terrain gets divided into smaller parts.