Up to date

This page is up to date for Godot 4.0. If you still find outdated information, please open an issue.


Inherits: Shape2D < Resource < RefCounted < Object

Convex polygon shape resource for 2D physics.


2D convex polygon shape to be added as a direct child of a PhysicsBody2D or Area2D using a CollisionShape2D node.

The shape is a solid that includes all the points that it encloses, as opposed to ConcavePolygonShape2D which is hollow if it encloses anything. See also CollisionPolygon2D.

The solid nature of the shape makes it well-suited for both detection and physics; in physics body interactions this allows depenetrating even those shapes which end up (e.g. due to high speed) fully inside the convex shape (similarly to primitive shapes, but unlike ConcavePolygonShape2D). The convexity limits the possible geometric shape of a single ConvexPolygonShape2D: it cannot be concave.

Convex decomposition: Concave objects' collisions can be represented accurately using several convex shapes. This allows dynamic physics bodies to have complex concave collisions (at a performance cost). It can be achieved using several ConvexPolygonShape2D nodes or by using the CollisionPolygon2D node in Solids build mode. To generate a collision polygon from a sprite, select the Sprite2D node, go to the Sprite2D menu that appears above the viewport, and choose Create Polygon2D Sibling.

Performance: ConvexPolygonShape2D is faster to check collisions against compared to ConcavePolygonShape2D, but it is slower than primitive collision shapes such as CircleShape2D or RectangleShape2D. Its use should generally be limited to medium-sized objects that cannot have their collision accurately represented by primitive shapes.







set_point_cloud ( PackedVector2Array point_cloud )

Property Descriptions

PackedVector2Array points = PackedVector2Array()

The polygon's list of vertices that form a convex hull. Can be in either clockwise or counterclockwise order.

Warning: Only set this property to a list of points that actually form a convex hull. Use set_point_cloud to generate the convex hull of an arbitrary set of points.

Method Descriptions

void set_point_cloud ( PackedVector2Array point_cloud )

Based on the set of points provided, this assigns the points property using the convex hull algorithm, removing all unneeded points. See Geometry2D.convex_hull for details.