Class ConcavePolygonShape2D
- Namespace
- Godot
- Assembly
- GodotSharp.dll
A 2D polyline shape, intended for use in physics. Used internally in CollisionPolygon2D when it's in Segments mode.
Being just a collection of interconnected line segments, ConcavePolygonShape2D is the most freely configurable single 2D shape. It can be used to form polygons of any nature, or even shapes that don't enclose an area. However, ConcavePolygonShape2D is hollow even if the interconnected line segments do enclose an area, which often makes it unsuitable for physics or detection.
Note: When used for collision, ConcavePolygonShape2D is intended to work with static CollisionShape2D nodes like StaticBody2D and will likely not behave well for CharacterBody2Ds or RigidBody2Ds in a mode other than Static.
Warning: Physics bodies that are small have a chance to clip through this shape when moving fast. This happens because on one frame, the physics body may be on the "outside" of the shape, and on the next frame it may be "inside" it. ConcavePolygonShape2D is hollow, so it won't detect a collision.
Performance: Due to its complexity, ConcavePolygonShape2D is the slowest 2D collision shape to check collisions against. Its use should generally be limited to level geometry. If the polyline is closed, CollisionPolygon2D's Solids mode can be used, which decomposes the polygon into convex ones; see ConvexPolygonShape2D's documentation for instructions.
public class ConcavePolygonShape2D : Shape2D, IDisposable
- Inheritance
-
ConcavePolygonShape2D
- Implements
- Inherited Members
Constructors
ConcavePolygonShape2D()
public ConcavePolygonShape2D()
Properties
Segments
The array of points that make up the ConcavePolygonShape2D's line segments. The array (of length divisible by two) is naturally divided into pairs (one pair for each segment); each pair consists of the starting point of a segment and the endpoint of a segment.
public Vector2[] Segments { get; set; }
Property Value
- Vector2[]
Methods
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.