Up to date

This page is up to date for Godot 4.0. If you still find outdated information, please open an issue.

CollisionPolygon3D

Inherits: Node3D < Node < Object

Node that represents a 3D collision polygon, given by the thickening of a 2D polygon in the local XY plane along the local Z axis.

Description

Provides a 3D collision polygon to a CollisionObject3D parent, by thickening a 2D (convex or concave) polygon in the local XY plane along the local Z axis. The 2D polygon in the local XY plane can be drawn in the editor or specified by a list of vertices. That 2D polygon is thickened evenly in the local Z and -Z directions.

This node has the same effect as several ConvexPolygonShape3D nodes, created by thickening the 2D convex polygons in the convex decomposition of the given 2D polygon (but without the overhead of multiple nodes).

Warning: A non-uniformly scaled CollisionPolygon3D node will probably not function as expected. Please make sure to keep its scale uniform (i.e. the same on all axes), and change its polygon's vertices instead.

Properties

float

depth

1.0

bool

disabled

false

float

margin

0.04

PackedVector2Array

polygon

PackedVector2Array()


Property Descriptions

float depth = 1.0

  • void set_depth ( float value )

  • float get_depth ( )

Length that the resulting collision extends in either direction perpendicular to its 2D polygon.


bool disabled = false

  • void set_disabled ( bool value )

  • bool is_disabled ( )

If true, no collision will be produced.


float margin = 0.04

  • void set_margin ( float value )

  • float get_margin ( )

The collision margin for the generated Shape3D. See Shape3D.margin for more details.


PackedVector2Array polygon = PackedVector2Array()

Array of vertices which define the 2D polygon in the local XY plane.

Note: The returned value is a copy of the original. Methods which mutate the size or properties of the return value will not impact the original polygon. To change properties of the polygon, assign it to a temporary variable and make changes before reassigning the polygon member.