Free · local · Godot 4

Collision Polygon Generator

Stop hand-drawing collision shapes. Trace the silhouette, simplify it, and export a CollisionPolygon2D scene or JSON.

Transparent PNG for Alpha mode; a flat background for Flat color mode.

Load a sprite to start.

Outline preview

The traced polygons will appear here.

Output: one CollisionPolygon2D per contour, in image pixels from the top-left.

How it works

  1. The image is converted to a binary mask: alpha above the threshold, or pixels far enough from the key color.
  2. Marching squares finds the contour at the mask boundary.
  3. Douglas–Peucker simplification removes redundant points.
  4. Each contour becomes a CollisionPolygon2D node in the .tscn.

Alpha or flat color?

SourceMode
Transparent PNG (sprite sheet, cutout)Alpha
Opaque sprite on green/magenta/grayFlat color key
Photo or painted backgroundUse a matte first, then Alpha
Concave shapes: Godot can decompose a concave 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.