Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.


Inherits: Shape2D < Resource < RefCounted < Object

用于物理碰撞的 2D 凸多边形形状。


A 2D convex polygon shape, intended for use in physics. Used internally in CollisionPolygon2D when it's in CollisionPolygon2D.BUILD_SOLIDS mode.

ConvexPolygonShape2D is solid, which means it detects collisions from objects that are fully inside it, unlike ConcavePolygonShape2D which is hollow. This makes it more suitable for both detection and physics.

Convex decomposition: A concave polygon can be split up into several convex polygons. This allows dynamic physics bodies to have complex concave collisions (at a performance cost) and can be achieved by using several ConvexPolygonShape2D nodes or by using the CollisionPolygon2D node in CollisionPolygon2D.BUILD_SOLIDS 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 and 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()


警告:请务必将这个属性设置为能够形成凸包的顶点列表。可以使用 set_point_cloud 从任意顶点集生成凸包。

Method Descriptions

void set_point_cloud ( PackedVector2Array point_cloud )

根据提供的点集,使用凸包算法分配 points 属性,移除所有不必要的点。详见 Geometry2D.convex_hull