CollisionPolygon2D
继承: Node2D < CanvasItem < Node < Object
向 CollisionObject2D 父级提供多边形形状的节点。
描述
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.
Warning: 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.
属性
|
||
|
||
|
||
|
||
|
枚举
enum BuildMode: 🔗
BuildMode BUILD_SOLIDS = 0
碰撞包含多边形及其内部区域。在这个模式下,该节点的效果与使用若干 ConvexPolygonShape2D 节点相同,其中的每个节点都包含该多边形凸分解后的凸形状(但不会有使用多个节点的负担)。
BuildMode BUILD_SEGMENTS = 1
碰撞仅包含多边形的边缘。在这个模式下,该节点的效果与单个由若干线段组成的 ConcavePolygonShape2D 相同,其中(第一条以后的)每条线段都从上一条的终点开始,最后一条线段在第一条的起点结束(构成闭合但中空的多边形)。
属性说明
碰撞构建模式。
如果为 true,则不会检测到碰撞。该属性应使用 Object.set_deferred() 进行更改。
bool one_way_collision = false 🔗
如果为 true,则只有面朝上的边缘才会与其他对象发生碰撞,方向是相对于 CollisionPolygon2D 的旋转而言的。
注意:如果这个 CollisionPolygon2D 是 Area2D 节点的子节点,则这个属性无效。
float one_way_collision_margin = 1.0 🔗
用于单向碰撞的边距(以像素为单位)。较高的值将使形状更厚,并且对于以高速进入多边形的对撞机来说效果更好。
PackedVector2Array polygon = PackedVector2Array() 🔗
void set_polygon(value: PackedVector2Array)
PackedVector2Array get_polygon()
多边形的顶点列表。每个点都与下一个点相连,最后一个点与第一个点相连。
注意:返回的顶点位于给定的 CollisionPolygon2D 的局部坐标空间中。
Note: The returned array is copied and any changes to it will not update the original property value. See PackedVector2Array for more details.