PhysicsDirectSpaceState3D
繼承: Object
被繼承: PhysicsDirectSpaceState3DExtension
提供對 PhysicsServer3D 中物理空間的直接存取。
說明
Provides direct access to a physics space in the PhysicsServer3D. It's used mainly to do queries against objects and areas residing in a given space.
Note: This class is not meant to be instantiated directly. Use World3D.direct_space_state to get the world's physics 3D space state.
教學
方法
cast_motion(parameters: PhysicsShapeQueryParameters3D) |
|
collide_shape(parameters: PhysicsShapeQueryParameters3D, max_results: int = 32) |
|
get_rest_info(parameters: PhysicsShapeQueryParameters3D) |
|
intersect_point(parameters: PhysicsPointQueryParameters3D, max_results: int = 32) |
|
intersect_ray(parameters: PhysicsRayQueryParameters3D) |
|
intersect_shape(parameters: PhysicsShapeQueryParameters3D, max_results: int = 32) |
方法說明
PackedFloat32Array cast_motion(parameters: PhysicsShapeQueryParameters3D) 🔗
Checks how far a Shape3D can move without colliding. All the parameters for the query, including the shape and the motion, are supplied through a PhysicsShapeQueryParameters3D object.
Returns an array with the safe and unsafe proportions (between 0 and 1) of the motion. The safe proportion is the maximum fraction of the motion that can be made without a collision. The unsafe proportion is the minimum fraction of the distance that must be moved for a collision. If no collision is detected a result of [1.0, 1.0] will be returned.
Note: Any Shape3Ds that the shape is already colliding with e.g. inside of, will be ignored. Use collide_shape() to determine the Shape3Ds that the shape is already colliding with.
Array[Vector3] collide_shape(parameters: PhysicsShapeQueryParameters3D, max_results: int = 32) 🔗
檢查通過 PhysicsShapeQueryParameters3D 物件給出的一個形狀與該空間的交點。結果陣列包含該形狀與另一個形狀相交處的點的列表。與 intersect_shape() 一樣,可以限制返回結果的數量以節省處理時間。
返回的點是接觸點對的一個列表。對於每一對,第一個是在 PhysicsShapeQueryParameters3D 對象中傳遞的形狀,第二個是來自物理空間的碰撞形狀。
注意:該方法不考慮物件的 motion 屬性。
Dictionary get_rest_info(parameters: PhysicsShapeQueryParameters3D) 🔗
Checks the intersections of a shape, given through a PhysicsShapeQueryParameters3D object, against the space. If it collides with more than one shape, the nearest one is selected. The returned object is a dictionary containing the following fields:
collider_id: The colliding object's ID.
linear_velocity: The colliding object's velocity Vector3. If the object is an Area3D, the result is (0, 0, 0).
normal: The collision normal of the query shape at the intersection point, pointing away from the intersecting object.
point: The intersection point.
rid: The intersecting object's RID.
shape: The shape index of the colliding shape.
If the shape did not intersect anything, then an empty dictionary is returned instead.
Note: This method does not take into account the motion property of the object.
Array[Dictionary] intersect_point(parameters: PhysicsPointQueryParameters3D, max_results: int = 32) 🔗
檢查點是否在任何實體形狀內。位置和其他參數通過 PhysicsPointQueryParameters3D 定義。點所在的形狀會以陣列的形式返回,該陣列包含有以下欄位的字典:
collider:碰撞對象。
collider_id:碰撞對象的 ID。
rid:相交對象的RID。
shape:碰撞形狀的形狀索引。
可以使用 max_results 參數限制相交的數量,以減少處理時間。
Dictionary intersect_ray(parameters: PhysicsRayQueryParameters3D) 🔗
在給定空間中偵測與射線的相交情況。射線的位置和其他參數由 PhysicsRayQueryParameters3D 定義。返回的物件是包含以下欄位的字典:
collider:碰撞到的對象。
collider_id:碰撞到的對象的 ID。
normal:該物件表面交點處的法線,如果射線中該形狀的內部開始,並且 PhysicsRayQueryParameters3D.hit_from_inside 為 true,則為 Vector3(0, 0, 0)。
position:交點。
face_index:交點處的面索引。
注意:只有相交形狀是 ConcavePolygonShape3D 時才會返回有效值。否則返回 -1。
rid:相交對象的 RID。
shape:碰撞形狀的形狀索引。
如果射線沒有發生相交,則返回的是空字典。
Array[Dictionary] intersect_shape(parameters: PhysicsShapeQueryParameters3D, max_results: int = 32) 🔗
檢查通過 PhysicsShapeQueryParameters3D 物件給出的形狀與空間的交點。相交的形狀在包含具有以下欄位的字典的陣列中返回:
collider:碰撞對象。
collider_id:碰撞對象的 ID。
rid:相交對象的 RID。
shape:碰撞形狀的形狀索引。
可以使用 max_results 參數限制相交的數量,以減少處理時間。
注意:該方法不考慮物件的 motion 屬性。