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...
CollisionObject3D
被繼承: Area3D, PhysicsBody3D
3D 物理物件的抽象基底類別。
說明
3D 物理物件的抽象基底類別。CollisionObject3D 能夠容納任意數量的 Shape3D 用作碰撞形狀。每個形狀必須分配給一個形狀所有者。形狀所有者不是節點,也不會出現在編輯器中,但可以通過程式碼使用 shape_owner_* 方法存取。
警告:如果使用非均勻縮放,則該節點可能無法按預期工作。建議讓所有軸上的縮放保持一致,可以用對碰撞形狀的調整來代替非均勻縮放。
屬性
|
||
|
||
|
||
|
||
|
||
|
方法
訊號
input_event(camera: Node, event: InputEvent, event_position: Vector3, normal: Vector3, shape_idx: int) 🔗
Emitted when the object receives an unhandled InputEvent. event_position is the location in world space of the mouse pointer on the surface of the shape with index shape_idx and normal is the normal vector of the surface at that point.
mouse_entered() 🔗
當滑鼠指標進入該物件的任何形狀時發出。要求 input_ray_pickable 為 true 並且至少設定了一個 collision_layer 位。
注意:由於缺少連續的碰撞偵測,如果滑鼠移動得足夠快並且 CollisionObject3D 的區域很小,則該訊號可能不會按預期的順序發出。如果另一個 CollisionObject3D 與所討論的 CollisionObject3D 重疊,則也可能不會發出該信號。
mouse_exited() 🔗
當滑鼠指標離開該物件的所有形狀時發出。要求 input_ray_pickable 為 true 並且至少設定了一個 collision_layer 位。
注意:由於缺少連續的碰撞偵測,如果滑鼠移動得足夠快並且 CollisionObject3D 的區域很小,則該訊號可能不會按預期的順序發出。如果另一個 CollisionObject3D 與所討論的 CollisionObject3D 重疊,則也可能不會發出該信號。
列舉
enum DisableMode: 🔗
DisableMode DISABLE_MODE_REMOVE = 0
當 Node.process_mode 被設定為 Node.PROCESS_MODE_DISABLED 時,從物理模擬中移除,停止與此 CollisionObject3D 的所有物理互動。
當該 Node 再次被處理時,會自動重新加入到物理模擬中。
DisableMode DISABLE_MODE_MAKE_STATIC = 1
當 Node.process_mode 被設定為 Node.PROCESS_MODE_DISABLED 時,使實體靜態化。不影響 Area3D。PhysicsBody3D 在靜態時不會受到力或其他實體的影響。
當該 Node 再次被處理時,自動將 PhysicsBody3D 設定回其原始模式。
DisableMode DISABLE_MODE_KEEP_ACTIVE = 2
當 Node.process_mode 被設定為 Node.PROCESS_MODE_DISABLED 時,不影響物理模擬。
屬性說明
該 CollisionObject3D 所在的實體層。碰撞物件可以存在於 32 個不同層中的一層或多層。另見 collision_mask。
注意:只有當物件 B 位於物件 A 掃描的任何層中時,物件 A 才能偵測到與對象 B 的接觸。有關更多資訊,請參閱文件中的《碰撞層和遮罩》。
該 CollisionObject3D 掃描的實體層。碰撞物件可以掃描 32 個不同層中的一層或多層。另見 collision_layer。
注意:只有當物件 B 位於物件 A 掃描的任何層中時,物件 A 才能偵測到與對象 B 的接觸。有關更多資訊,請參閱文件中的《碰撞層和遮罩》。
float collision_priority = 1.0 🔗
發生穿透時用於解決碰撞的優先順序。優先順序越高,對物體的穿透度就越低。例如,可以用來防止玩家突破關卡的邊界。
DisableMode disable_mode = 0 🔗
void set_disable_mode(value: DisableMode)
DisableMode get_disable_mode()
Defines the behavior in physics when Node.process_mode is set to Node.PROCESS_MODE_DISABLED.
bool input_capture_on_drag = false 🔗
如果為 true,則當滑鼠拖過其形狀時,CollisionObject3D 將繼續接收輸入事件。
bool input_ray_pickable = true 🔗
如果為 true,則該對象是可拾取的。可拾取的物件可以偵測滑鼠指標的進入/離開,滑鼠位於其中時,就會報告輸入事件。要求至少設定一個 collision_layer 位。
方法說明
void _input_event(camera: Camera3D, event: InputEvent, event_position: Vector3, normal: Vector3, shape_idx: int) virtual 🔗
Receives unhandled InputEvents. event_position is the location in world space of the mouse pointer on the surface of the shape with index shape_idx and normal is the normal vector of the surface at that point. Connect to the input_event signal to easily pick up these events.
Note: _input_event() requires input_ray_pickable to be true and at least one collision_layer bit to be set.
void _mouse_enter() virtual 🔗
當滑鼠指標進入該實體的任何形狀時呼叫。要求 input_ray_pickable 為 true 並且至少設定一個 collision_layer 位。請注意,在單個 CollisionObject3D 中的不同形狀之間移動,不會導致該函式被呼叫。
void _mouse_exit() virtual 🔗
當滑鼠指標離開該實體的所有形狀時呼叫。要求 input_ray_pickable 為 true 並且至少設定一個 collision_layer 位。請注意,在單個 CollisionObject3D 中的不同形狀之間移動,不會導致該函式被呼叫。
int create_shape_owner(owner: Object) 🔗
為給定物件建立一個新的形狀所有者。返回 owner_id的新所有者,供將來引用。
bool get_collision_layer_value(layer_number: int) const 🔗
返回 collision_layer 中是否啟用了指定的層,給定的 layer_number 應在 1 和 32 之間。
bool get_collision_mask_value(layer_number: int) const 🔗
返回 collision_mask 中是否啟用了指定的層,給定的 layer_number 應在 1 和 32 之間。
返回對象的 RID。
PackedInt32Array get_shape_owners() 🔗
返回一個 owner_id 識別字的 Array。你可以在其他使用 owner_id 作為參數的方法中使用這些 ID。
bool is_shape_owner_disabled(owner_id: int) const 🔗
如果為 true,則禁用形狀所有者及其形狀。
void remove_shape_owner(owner_id: int) 🔗
移除給定形狀的所有者。
void set_collision_layer_value(layer_number: int, value: bool) 🔗
根據 value,啟用或禁用 collision_layer 中指定的層,給定的 layer_number 應在 1 和 32 之間。
void set_collision_mask_value(layer_number: int, value: bool) 🔗
根據 value,啟用或禁用 collision_mask 中指定的層,給定的 layer_number 應在 1 和 32 之間。
int shape_find_owner(shape_index: int) const 🔗
返回指定形狀的 owner_id。
void shape_owner_add_shape(owner_id: int, shape: Shape3D) 🔗
向形狀擁有者新增 Shape3D。
void shape_owner_clear_shapes(owner_id: int) 🔗
移除形狀所有者的所有形狀。
Object shape_owner_get_owner(owner_id: int) const 🔗
返回給定形狀所有者的父物件。
Shape3D shape_owner_get_shape(owner_id: int, shape_id: int) const 🔗
返回形狀所有者中具有給定 ID 的 Shape3D。
int shape_owner_get_shape_count(owner_id: int) const 🔗
返回給定形狀所有者包含的形狀數量。
int shape_owner_get_shape_index(owner_id: int, shape_id: int) const 🔗
返回形狀所有者中具有給定 ID 的 Shape3D 的子索引。
Transform3D shape_owner_get_transform(owner_id: int) const 🔗
返回形狀所有者的 Transform3D。
void shape_owner_remove_shape(owner_id: int, shape_id: int) 🔗
從給定的形狀所有者中移除一個形狀。
void shape_owner_set_disabled(owner_id: int, disabled: bool) 🔗
如果為 true,則禁用給定的形狀所有者。
void shape_owner_set_transform(owner_id: int, transform: Transform3D) 🔗
設定給定形狀所有者的 Transform3D。