PhysicsDirectSpaceState¶
继承: Object
类别: 核心
简要说明¶
直接访问对象到 PhysicsServer .
方法¶
cast_motion ( PhysicsShapeQueryParameters shape, Vector3 motion ) |
|
collide_shape ( PhysicsShapeQueryParameters shape, int max_results=32 ) |
|
get_rest_info ( PhysicsShapeQueryParameters shape ) |
|
intersect_ray ( Vector3 from, Vector3 to, Array exclude=[ ], int collision_mask=2147483647, bool collide_with_bodies=true, bool collide_with_areas=false ) |
|
intersect_shape ( PhysicsShapeQueryParameters shape, int max_results=32 ) |
描述¶
直接访问对象到 PhysicsServer . 它主要用于查询特定空间中的对象和区域。
方法说明¶
Array cast_motion ( PhysicsShapeQueryParameters shape, Vector3 motion )
检查形状是否可以移动到某个点。该方法将返回一个数组,其中两个浮点数介于0和1之间,都表示 motion
. 第一个是形状在不触发碰撞的情况下可以移动多远,第二个是发生碰撞的点。如果未检测到冲突,则返回的数组将 [1, 1]
.
如果形状不能移动,则返回的数组将 [0, 0]
在子弹之下,在哥多物理之下是空的。
Array collide_shape ( PhysicsShapeQueryParameters shape, int max_results=32 )
检查形状的交叉点,通过 PhysicsShapeQueryParameters 物体,对着空间。结果数组包含形状与其他形状相交的点列表。就像 intersect_shape ,可以限制返回结果的数量以节省处理时间。
Dictionary get_rest_info ( PhysicsShapeQueryParameters shape )
检查形状的交叉点,通过 PhysicsShapeQueryParameters 物体,对着空间。如果与多个形状碰撞,则选择最近的形状。返回的对象是包含以下字段的字典:
collider_id
:碰撞对象的ID。
linear_velocity
碰撞物体的速度 Vector3 . 如果对象是 Area ,结果是 (0, 0, 0)
.
normal
:在交叉点处对象的曲面法线。
point
:交叉点。
rid
:相交对象的 RID .
shape
:碰撞形状的形状索引。
如果形状没有与任何内容相交,则返回空字典。
Dictionary intersect_ray ( Vector3 from, Vector3 to, Array exclude=[ ], int collision_mask=2147483647, bool collide_with_bodies=true, bool collide_with_areas=false )
与给定空间中的光线相交。返回的对象是具有以下字段的字典:
collider
:碰撞对象。
collider_id
:碰撞对象的ID。
normal
:在交叉点处对象的曲面法线。
position
:交叉点。
rid
:相交对象的 RID .
shape
:碰撞形状的形状索引。
如果光线没有与任何东西相交,则返回空字典。
此外,该方法可以采用 exclude
对象数组或 RID 将从碰撞中排除的,a collision_mask
表示要检入的物理层的位掩码,或用于确定光线是否应与之碰撞的布尔值。 PhysicsBody S或 Area 分别是。
Array intersect_shape ( PhysicsShapeQueryParameters shape, int max_results=32 )
检查形状的交叉点,通过 PhysicsShapeQueryParameters 物体,对着空间。相交的形状将在包含字典的数组中返回,其中包含以下字段:
collider
:碰撞对象。
collider_id
:碰撞对象的ID。
rid
:相交对象的 RID .
shape
:碰撞形状的形状索引。
交叉口的数量可以用 max_results
参数,减少处理时间。