Table of Contents

Class CollisionPolygon2D

A node that provides a polygon shape to a CollisionObject2D parent.

Inheritance
CollisionPolygon2D

Remarks

A node that provides a polygon shape to a CollisionObject2D parent and allows to edit it. The polygon can be concave or convex. This can give a detection shape to an Area2D, turn 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.

Properties

build_mode

Collision build mode. Use one of the BuildMode constants.

var build_mode : int = 0

Property Value

int

Remarks

  • void set_build_mode(int value)
  • int get_build_mode

disabled

If true, no collisions will be detected.

var disabled : bool = false

Property Value

bool

Remarks

  • void set_disabled(bool value)
  • bool is_disabled

one_way_collision

If true, only edges that face up, relative to CollisionPolygon2D's rotation, will collide with other objects.

Note: This property has no effect if this CollisionPolygon2D is a child of an Area2D node.

var one_way_collision : bool = false

Property Value

bool

Remarks

  • void set_one_way_collision(bool value)
  • bool is_one_way_collision_enabled

one_way_collision_margin

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.

var one_way_collision_margin : float = 1.0

Property Value

float

Remarks

  • void set_one_way_collision_margin(float value)
  • float get_one_way_collision_margin

polygon

The polygon's list of vertices. Each point will be connected to the next, and the final point will be connected to the first.

Note: The returned vertices are in the local coordinate space of the given CollisionPolygon2D.

var polygon : PackedVector2Array = PackedVector2Array()

Property Value

PackedVector2Array

Remarks