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.
Checking the stable version of the documentation...
ConcavePolygonShape2D¶
Inherits: Shape2D < Resource < RefCounted < Object
用于物理碰撞的 2D 多线段形状。
Description¶
A 2D polyline shape, intended for use in physics. Used internally in CollisionPolygon2D when it's in CollisionPolygon2D.BUILD_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, ConvexPolygonShape2D 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 CollisionPolygon2D.BUILD_SOLIDS mode can be used, which decomposes the polygon into convex ones; see ConvexPolygonShape2D's documentation for instructions.
Properties¶
|
Property Descriptions¶
PackedVector2Array segments = PackedVector2Array()
void set_segments ( PackedVector2Array value )
PackedVector2Array get_segments ( )
顶点数组,构成 ConcavePolygonShape2D 的线段。该(长度能被二整除的)数组自然两两分组(每组代表一条线段);每组都由一条线段的起点和终点构成。