Collision Polygon Generator
Stop hand-drawing collision shapes. Trace the silhouette, simplify it, and export a
CollisionPolygon2D scene or JSON.
Load a sprite to start.
Outline preview
CollisionPolygon2D per contour, in image
pixels from the top-left.
How it works
- The image is converted to a binary mask: alpha above the threshold, or pixels far enough from the key color.
- Marching squares finds the contour at the mask boundary.
- Douglas–Peucker simplification removes redundant points.
- Each contour becomes a
CollisionPolygon2Dnode in the.tscn.
Alpha or flat color?
| Source | Mode |
|---|---|
| Transparent PNG (sprite sheet, cutout) | Alpha |
| Opaque sprite on green/magenta/gray | Flat color key |
| Photo or painted background | Use a matte first, then Alpha |
CollisionPolygon2D,
but a simpler polygon is cheaper. Raise the simplify value until the outline still fits.
Using the .tscn
Drop the .tscn into your project, open it, and drag the
CollisionPolygons node under your Sprite2D or
AnimatedSprite2D. The points are in image pixels, so the parent should sit at
the sprite's top-left (or offset it by half the frame if your sprite is centered).
FAQ
Does this upload my sprite?
No. The image is decoded and traced in the browser; the .tscn and JSON are generated locally.
Alpha or flat color?
Use Alpha for a transparent PNG. Use Flat color when the sprite is opaque but sits on a solid background, such as a green screen.
Why does a hole become a separate polygon?
CollisionPolygon2D does not describe holes. The tracer emits each contour as its own polygon; for a ring, that means an outer and an inner shape.
What does the tolerance do?
It simplifies the traced edge. A higher value gives fewer points and a looser fit; 1–2 px is a good start for pixel art.
Where do the points go in Godot?
They are in image pixels, relative to the top-left. The .tscn places the polygons under a Node2D at (0, 0); put it under your Sprite2D and adjust the position.