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.

PhysicsRayQueryParameters2D

繼承: RefCounted < Object

PhysicsDirectSpaceState2D.intersect_ray() 提供參數。

說明

通過修改這個物件的射線位置等屬性,你可以為 PhysicsDirectSpaceState2D.intersect_ray() 配置參數。

屬性

bool

collide_with_areas

false

bool

collide_with_bodies

true

int

collision_mask

4294967295

Array[RID]

exclude

[]

Vector2

from

Vector2(0, 0)

bool

hit_from_inside

false

Vector2

to

Vector2(0, 0)

方法

PhysicsRayQueryParameters2D

create(from: Vector2, to: Vector2, collision_mask: int = 4294967295, exclude: Array[RID] = []) static


屬性說明

bool collide_with_areas = false 🔗

  • void set_collide_with_areas(value: bool)

  • bool is_collide_with_areas_enabled()

如果為 true,查詢將考慮 Area2D


bool collide_with_bodies = true 🔗

  • void set_collide_with_bodies(value: bool)

  • bool is_collide_with_bodies_enabled()

如果為 true,查詢將考慮 PhysicsBody2D


int collision_mask = 4294967295 🔗

  • void set_collision_mask(value: int)

  • int get_collision_mask()

查詢將偵測的實體層(作為位元遮罩)。預設情況下,會偵測所有碰撞層。有關詳細信息,請參閱文件中的 《碰撞層和遮罩》


Array[RID] exclude = [] 🔗

The list of object RIDs that will be excluded from collisions. Use CollisionObject2D.get_rid() to get the RID associated with a CollisionObject2D-derived node.

Note: The returned array is copied and any changes to it will not update the original property value. To update the value you need to modify the returned array, and then assign it to the property again.


Vector2 from = Vector2(0, 0) 🔗

要查詢的射線起點,使用全域座標。


bool hit_from_inside = false 🔗

  • void set_hit_from_inside(value: bool)

  • bool is_hit_from_inside_enabled()

如果為 true,查詢會在從形狀內部開始時偵測到命中。在此情況下,碰撞法線將為 Vector2(0, 0)。不會影響凹多邊形形狀。


Vector2 to = Vector2(0, 0) 🔗

要查詢的射線終點,使用全域座標。


方法說明

PhysicsRayQueryParameters2D create(from: Vector2, to: Vector2, collision_mask: int = 4294967295, exclude: Array[RID] = []) static 🔗

返回一個新的、預配置的 PhysicsRayQueryParameters2D 對象。使用它可以使用最常見的選項來快速建立查詢參數。

var query = PhysicsRayQueryParameters2D.create(global_position, global_position + Vector2(0, 100))
var collision = get_world_2d().direct_space_state.intersect_ray(query)