Godot Version
4.6
Question
I want to add collisions to dynamically generated meshes in 2D but my current approach isn’t working.
var mdt := MeshDataTool.new()
mdt.create_from_surface(mesh, 0)
var polygon := PackedVector2Array()
for i in mdt.get_vertex_count():
var vertex := mdt.get_vertex(i)
polygon.append(Vector2(vertex.x, vertex.y))
First, this approach doesn’t create a collision shapes for each individual area. It should only create collisions for the walls in white.
Second, I get this error:
E 0:00:00:387 decompose_many_polygons_in_convex: Convex decomposing failed!
<C++ Source> core/math/geometry_2d.cpp:101 @ decompose_many_polygons_in_convex()
How can I fix these issues in a performant way? Are there built in functions I could use which I am unaware of? Thanks!
