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.
Checking the stable version of the documentation...
CollisionShape2D
繼承: Node2D < CanvasItem < Node < Object
向 CollisionObject2D 父級提供 Shape2D 的節點。
說明
向 CollisionObject2D 父級提供 Shape2D 並能對其編輯的節點。這可以爲 Area2D 提供偵測形狀,或將 PhysicsBody2D 轉變爲實體物件。
教學
屬性
|
||
|
||
|
||
|
||
|
||
屬性說明
Color debug_color = Color(0, 0, 0, 0) 🔗
碰撞形狀的顏色,在編輯器中顯示,勾選編輯器頂部的 除錯 > 顯示碰撞形狀 時也會在執行專案時顯示。
注意:預設值為 ProjectSettings.debug/shapes/collision/shape_color。這裡記錄的 Color(0, 0, 0, 0) 值是佔位符,不是實際的預設除錯顏色。
停用的碰撞形狀在世界中沒有影響。這個屬性應該用 Object.set_deferred() 改變。
bool one_way_collision = false 🔗
設定此碰撞形狀是否僅應檢測到一側(頂部或底部)的碰撞。
注意:如果這個 CollisionShape2D 是 Area2D 節點的子節點,則這個屬性無效。
注意:單向碰撞的方向可以通過設定 one_way_collision_direction 來設定。
Vector2 one_way_collision_direction = Vector2(0, 1) 🔗
用於單向碰撞的方向。
float one_way_collision_margin = 1.0 🔗
用於單向碰撞的邊距(以圖元為單位)。較高的值將使形狀更厚,並且對於高速進入形狀的對撞機來說效果更好。
該碰撞形狀擁有的實際形狀。