Open vbettaque opened 2 months ago
This would just be ConcavePolygonShape2D
but not closed, as that shape has no interior but only checks against the segments
Precisely. I was considering proposing the addition of a flag to have ConcavePolygonShape2D
be non-closed as an alternative, but it would not be a polygon anymore so I didn't find it fitting.
Okay after reading more about it, I guess ConcavePolygonShape2d
does look like what I want (except that its individual segments do not necessarily have to be connected it seems?). But I'd argue that the name is a misnomer then, which is why I didn't find it earlier. Also Godot give you a warning if you try to use ConcavePolygonShape2d
outside CollisionPolygon2D
(this is not mentioned in the documentation), so clearly the direct usage is not encouraged.
Describe the project you are working on
A Pokemon Ranger-like game where the player leaves a trail behind to encircle enemies. The trail is destroyed/damaged if enemies collide with it.
Describe the problem or limitation you are having in your project
It is not straightforward to detect collision with a polyline composed of multiple (possibly intersecting) line segments. There are multiple options, which all fall short in some regard:
Each segment of the polyline can be given collision individually using
SegmentShape2D
. However for the aforementioned project this might require adding/removing/keeping track of a large number of differentCollisionShape2D
nodes during each physics step, which is unreasonable and inefficient.One could use
offset_polyline
. However this is also cumbersome to use if the polyline has intersections, and also might fail on occasion.Describe the feature / enhancement and how it helps to overcome the problem or limitation
I propose to add a new subresource of
Shape2D
which represents a single polyline and would therefore be able to resolve the aforementioned problems in an elegant way. Such a resource is also present in other engines, e.g. Rapier.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
PolylineShape2D
would be very similar toSegmentShape2D
, but would accept aPackedVector2Array
instead of just two points. The required physics/collision detection is also straightforward to implement due to the the polyline being composed of individual segments, for which these routines already exist in the engine.If this enhancement will not be used often, can it be worked around with a few lines of script?
As mentioned before, it is technically possible to work around these limitations, but not in a few lines of script and not efficiently.
Is there a reason why this should be core and not an add-on in the asset library?
It is not possible to extend physics engine behavior through an external add-on.