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.

CollisionPolygon3D

继承: Node3D < Node < Object

CollisionObject3D 父级提供加厚多边形形状(角柱体)的节点。

描述

CollisionObject3D 父级提供加厚多边形形状(角柱体)的节点,能够为这个形状提供编辑的方法。该多边形可以是凹多边形,也可以是凸多边形。能够为 Area3D 提供检测形状,也能够将 PhysicsBody3D 变为实体。

警告:非均匀缩放的 CollisionShape3D 应该无法按预期工作。请确保它在所有轴上的缩放是一致的,可以用对形状资源的调整来代替非均匀缩放。

属性

Color

debug_color

Color(0, 0, 0, 0)

bool

debug_fill

true

float

depth

1.0

bool

disabled

false

float

margin

0.04

PackedVector2Array

polygon

PackedVector2Array()


属性说明

Color debug_color = Color(0, 0, 0, 0) 🔗

  • void set_debug_color(value: Color)

  • Color get_debug_color()

碰撞形状的颜色,在编辑器中显示,勾选编辑器顶部的 调试 > 显示碰撞形状 时也会在运行项目时显示。

注意:默认值为 ProjectSettings.debug/shapes/collision/shape_color。这里记录的 Color(0, 0, 0, 0) 值是占位符,不是实际的默认调试颜色。


bool debug_fill = true 🔗

  • void set_enable_debug_fill(value: bool)

  • bool get_enable_debug_fill()

如果为 true,则显示形状时除了显示线框外还会显示填充颜色。


float depth = 1.0 🔗

产生的碰撞沿着与 2D 多边形垂直的任意方向深入的长度。


bool disabled = false 🔗

  • void set_disabled(value: bool)

  • bool is_disabled()

如果为 true,将不会产生碰撞。


float margin = 0.04 🔗

  • void set_margin(value: float)

  • float get_margin()

生成的 Shape3D 的碰撞边距。详见 Shape3D.margin


PackedVector2Array polygon = PackedVector2Array() 🔗

在局部 XY 平面中定义 2D 多边形的顶点数组。

Note: The returned array is copied and any changes to it will not update the original property value. See PackedVector2Array for more details.