Function Physics2DDirectSpaceState.intersectRay
Intersects a ray in a given space. The returned object is a dictionary with the following fields:
collider
: The colliding object.
collider_id
: The colliding object's ID.
metadata
: The intersecting shape's metadata. This metadata is different from GodotObject
, and is set with Physics2DServer
.
normal
: The object's surface normal at the intersection point.
position
: The intersection point.
rid
: The intersecting object's RID
.
shape
: The shape index of the colliding shape.
If the ray did not intersect anything, then an empty dictionary is returned instead.
Additionally, the method can take an exclude
array of objects or RID
s that are to be excluded from collisions, a collision_mask
bitmask representing the physics layers to check in, or booleans to determine if the ray should collide with PhysicsBody
s or Area
s, respectively.
Dictionary intersectRay
(
const(Vector2) from,
const(Vector2) to,
const(Array) exclude = make(),
const(long) collision_layer = 2147483647L,
const(bool) collide_with_bodies = true,
const(bool) collide_with_areas = false
) nothrow @nogc;