Skip to content
0.2.0-dev Download ZIP
29 lines ·2.4 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="ConvexPolygonShape2D" inherits="Shape2D" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A 2D convex polygon shape used for physics collision.
5 </brief_description>
6 <description>
7 A 2D convex polygon shape, intended for use in physics. Used internally in [CollisionPolygon2D] when it's in [constant CollisionPolygon2D.BUILD_SOLIDS] mode.
8 [ConvexPolygonShape2D] is [i]solid[/i], 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.
9 [b]Convex decomposition:[/b] 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 [constant CollisionPolygon2D.BUILD_SOLIDS] mode. To generate a collision polygon from a sprite, select the [Sprite2D] node, go to the [b]Sprite2D[/b] menu that appears above the viewport, and choose [b]Create Polygon2D Sibling[/b].
10 [b]Performance:[/b] [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.
11 </description>
12 <tutorials>
13 </tutorials>
14 <methods>
15 <method name="set_point_cloud">
16 <return type="void" />
17 <param index="0" name="point_cloud" type="PackedVector2Array" />
18 <description>
19 Based on the set of points provided, this assigns the [member points] property using the convex hull algorithm, removing all unneeded points. See [method Geometry2D.convex_hull] for details.
20 </description>
21 </method>
22 </methods>
23 <members>
24 <member name="points" type="PackedVector2Array" setter="set_points" getter="get_points" default="PackedVector2Array()">
25 The polygon's list of vertices that form a convex hull. Can be in either clockwise or counterclockwise order.
26 [b]Warning:[/b] Only set this property to a list of points that actually form a convex hull. Use [method set_point_cloud] to generate the convex hull of an arbitrary set of points.
27 </member>
28 </members>
29</class>