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,則不會產生碰撞。該屬性應使用 Object.set_deferred() 進行更改。


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.