Skip to main content

Function: raycast()

raycast(bodies, start, end, sort): RaycastCollision[]

Defined in: physics/raycast.ts:18

Raycast function that returns an array of RaycastCollision objects that represent the intersections between a ray and the bodies in the world.

Parameters

bodies

Body[]

The array of Matter.Body objects to check for intersections

start

Vector2

The starting point of the ray

end

Vector2

The ending point of the ray

sort

boolean = true

Whether to sort the results by distance from the start point

Returns

RaycastCollision[]

An array of RaycastCollision objects