Curve2Collision turns a Path2D curve into a thickened CollisionPolygon2D, and keeps it in sync automatically while you edit the curve. Useful for slopes, tubes, rails, cave walls — anything you would rather draw as a line than build vertex by vertex.
Usage
- Add a
StaticBody2D(orAnimatableBody2Dfor moving platforms,Area2Dfor detection only) to your scene. - Add a
CurveCollision2Dnode as its child.CollisionPolygon2Donly works as a direct child of aCollisionObject2D, so this parenting matters — the node shows a configuration warning if it is placed anywhere else. - Draw the curve as usual with the curve editing tools.
- Set
thickness. ACollisionPolygon2DnamedGeneratedCollisionis created and updated automatically.
StaticBody2D
├── CurveCollision2D <- you draw the curve here
└── GeneratedCollision <- generated CollisionPolygon2D
Properties
| Property | Type | Default | Description |
|---|---|---|---|
thickness |
float | 32.0 | Width of the band. Stays constant along the whole curve. |
closed_loop |
bool | false | Joins the start and end into a closed ring shape. |
tolerance_degrees |
float | 4.0 | Curve tessellation accuracy. Lower is smoother but adds vertices. |
max_vertices |
int | 120 | Cap on the centreline vertex count, for performance. |
join_type |
enum | Round | Corner style: Round / Square / Miter. |
end_type |
enum | Round | Cap style: Round / Square / Butt. Ignored when closed_loop is on. |
auto_update |
bool | true | Regenerate on every curve edit. Turn off for heavy curves. |
regenerate_now |
bool | false | Manual regeneration trigger. |
Self-intersection
Shapes are built with Godot's own Geometry2D.offset_polyline() / offset_polygon() (Clipper). Even when the thickness is large relative to a tight curve, the self-intersections that appear on the inner side are resolved correctly by the library — the band never pinches or distorts.
With closed_loop enabled, the outer and inner contours are offset separately and stitched into a ring. If the thickness is large enough that the inner contour disappears, the result becomes a solid blob.
Known limitations
join_type = Roundproduces smooth corners at the cost of more vertices. UseMiterorSquare, or tunetolerance_degrees/max_vertices, if you need it lighter.- Rectangle and circle frame shapes are not supported — curve-based shapes only.
- Auto-updating many curves at once can slow the editor down. Turn off
auto_updateand useregenerate_nowmanually in that case.
Requirements
Godot 4.x. Tested on 4.7.1.
MIT licensed. Source and issues: https://github.com/seina369/godot-curve2collision
Changelog for version v1.0.0
No changelog provided for this version.