CollisionObject
Inherits: Spatial < Node < Object
Inherited By: Area, PhysicsBody
碰撞对象的基础节点。
描述
CollisionObject 是物理对象的基类。它可以容纳任何数量的碰撞形状 Shape。每个形状必须分配给一个形状所有者 shape owner。CollisionObject 可以有任意数量的形状所有者。形状所有者不是节点,也不会出现在编辑器中,但是可以通过代码使用 shape_owner_*
方法进行访问。
属性
| ||
| ||
| ||
|
方法
信号
- input_event ( Node camera, InputEvent event, Vector3 position, Vector3 normal, int shape_idx )
当对象收到未处理的 InputEvent 时发出。 position
是鼠标指针在具有索引 shape_idx
的形状表面在世界空间中的位置,normal
是该点表面的法向量.
- mouse_entered ( )
当鼠标指针进入此对象的任何形状时触发。
- mouse_exited ( )
当鼠标指针退出此对象的所有形状时发出。
属性说明
- int collision_layer
Default |
|
Setter | set_collision_layer(value) |
Getter | get_collision_layer() |
The physics layers this CollisionObject3D is in. Collision objects can exist in one or more of 32 different layers. See also collision_mask.
Note: A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See Collision layers and masks in the documentation for more information.
- int collision_mask
Default |
|
Setter | set_collision_mask(value) |
Getter | get_collision_mask() |
The physics layers this CollisionObject3D scans. Collision objects can scan one or more of 32 different layers. See also collision_layer.
Note: A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See Collision layers and masks in the documentation for more information.
- bool input_capture_on_drag
Default |
|
Setter | set_capture_input_on_drag(value) |
Getter | get_capture_input_on_drag() |
如果true
,CollisionObject
将在鼠标拖过其形状时继续接收输入事件。
- bool input_ray_pickable
Default |
|
Setter | set_ray_pickable(value) |
Getter | is_ray_pickable() |
如果true
,CollisionObject
的形状将对 RayCast 做出反应。
方法说明
- void _input_event ( Object camera, InputEvent event, Vector3 position, Vector3 normal, int shape_idx ) virtual
接收未处理的事件 InputEvent。 position
是鼠标指针在具有索引 shape_idx
的形状表面在世界空间中的位置,normal
是该点表面的法向量。连接到 input_event 信号以轻松获取这些事件。
为给定对象创建一个新的形状拥有者。返回owner_id
的新所有者,供将来引用。
返回是否设置了碰撞层 collision_layer 的指定位bit
。
返回是否设置了碰撞掩码 collision_mask 的指定位bit
。
- RID get_rid ( ) const
返回对象的 RID。
- Array get_shape_owners ( )
返回一个owner_id
标识符的Array。你可以在其他使用owner_id
作为参数的方法中使用这些id。
如果true
,则禁用形状所有者及其形状。
- void remove_shape_owner ( int owner_id )
移除给定形状的所有者。
如果value
为true
,则设置collision_layer中指定的bit
位。
如果value
为false
,清除collision_layer中指定的 bit
位。
如果value
为true
,则设置collision_mask中指定的bit
位。
如果value
为false
,清除collision_mask中指定的 bit
位。
返回指定形状的owner_id
。
向形状所有者添加形状 Shape。
- void shape_owner_clear_shapes ( int owner_id )
移除形状所有者的所有形状。
返回给定形状所有者的父对象。
从给定的形状所有者返回具有给定 id 的形状 Shape。
返回给定形状所有者包含的形状数量。
返回具有给定形状所有者的给定 id 的形状 Shape 的子索引。
返回形状所有者的Transform。
从给定的形状所有者中删除一个形状。
如果true
,则禁用给定的形状所有者。
设置给定形状所有者的Transform。