Skip to content
0.2.0-dev Download ZIP
43 lines ·3.4 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="CollisionPolygon2D" inherits="Node2D" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A node that provides a polygon shape to a [CollisionObject2D] parent.
5 </brief_description>
6 <description>
7 A node that provides a polygon shape to a [CollisionObject2D] parent and allows it to be edited. The polygon can be concave or convex. This can give a detection shape to an [Area2D], turn a [PhysicsBody2D] into a solid object, or give a hollow shape to a [StaticBody2D].
8 [b]Warning:[/b] A non-uniformly scaled [CollisionPolygon2D] will likely not behave as expected. Make sure to keep its scale the same on all axes and adjust its polygon instead.
9 </description>
10 <tutorials>
11 </tutorials>
12 <members>
13 <member name="build_mode" type="int" setter="set_build_mode" getter="get_build_mode" enum="CollisionPolygon2D.BuildMode" default="0">
14 Collision build mode.
15 </member>
16 <member name="disabled" type="bool" setter="set_disabled" getter="is_disabled" default="false" keywords="enabled">
17 If [code]true[/code], no collisions will be detected. This property should be changed with [method Object.set_deferred].
18 </member>
19 <member name="one_way_collision" type="bool" setter="set_one_way_collision" getter="is_one_way_collision_enabled" default="false">
20 If [code]true[/code], only edges that face up, relative to [CollisionPolygon2D]'s rotation, will collide with other objects.
21 [b]Note:[/b] This property has no effect if this [CollisionPolygon2D] is a child of an [Area2D] node.
22 [b]Note:[/b] The one way collision direction can be configured by setting [member one_way_collision_direction].
23 </member>
24 <member name="one_way_collision_direction" type="Vector2" setter="set_one_way_collision_direction" getter="get_one_way_collision_direction" default="Vector2(0, 1)">
25 The direction used for one-way collision.
26 </member>
27 <member name="one_way_collision_margin" type="float" setter="set_one_way_collision_margin" getter="get_one_way_collision_margin" default="1.0">
28 The margin used for one-way collision (in pixels). Higher values will make the shape thicker, and work better for colliders that enter the polygon at a high velocity.
29 </member>
30 <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array()">
31 The polygon's list of vertices. Each point will be connected to the next, and the final point will be connected to the first.
32 [b]Note:[/b] The returned vertices are in the local coordinate space of the given [CollisionPolygon2D].
33 </member>
34 </members>
35 <constants>
36 <constant name="BUILD_SOLIDS" value="0" enum="BuildMode">
37 Collisions will include the polygon and its contained area. In this mode the node has the same effect as several [ConvexPolygonShape2D] nodes, one for each convex shape in the convex decomposition of the polygon (but without the overhead of multiple nodes).
38 </constant>
39 <constant name="BUILD_SEGMENTS" value="1" enum="BuildMode">
40 Collisions will only include the polygon edges. In this mode the node has the same effect as a single [ConcavePolygonShape2D] made of segments, with the restriction that each segment (after the first one) starts where the previous one ends, and the last one ends where the first one starts (forming a closed but hollow polygon).
41 </constant>
42 </constants>
43</class>