Skip to content

PhysicsIntersectRayResult2D

Inherits: RefCounted < Object

Stores the result of a ray intersection query.

This object contains the intersection information produced by PhysicsDirectSpaceState2D.intersect_ray_into().

After calling PhysicsDirectSpaceState2D.intersect_ray_into(), the fields of this object will be populated with the hit information if the ray intersects a shape. If no intersection occurred, the values remain unchanged from the previous state.

Note: For optimal performance results, it is recommended to create this object in advance, store it, and reuse it for every subsequent query.

Type Name Default
Object collider
int collider_id 0
RID collider_rid RID()
int collider_shape 0
Vector2 normal Vector2(0, 0)
Vector2 position Vector2(0, 0)

collider

Object collider

The colliding object.

collider_id

int collider_id = 0

The colliding object’s ID.

collider_rid

RID collider_rid = RID()

The intersecting object’s RID.

collider_shape

int collider_shape = 0

The shape index of the colliding shape.

normal

Vector2 normal = Vector2(0, 0)

The object’s surface normal at the intersection point, or Vector2(0, 0) if the ray starts inside the shape and PhysicsRayQueryParameters2D.hit_from_inside is true.

position

Vector2 position = Vector2(0, 0)

The intersection point.