castRay method

void castRay(
  1. Vector2 origin,
  2. Vector2 translation,
  3. double callback(
    1. RayHit hit
    ), {
  4. QueryFilter? filter,
})

Casts a ray from origin along translation, invoking callback for every candidate hit in an arbitrary order.

The callback controls the rest of the cast with its return value: -1 to ignore the hit, 0 to stop, the hit's fraction to clip the ray to the hit, or 1 to continue looking without clipping.

Implementation

void castRay(
  Vector2 origin,
  Vector2 translation,
  double Function(RayHit hit) callback, {
  QueryFilter? filter,
}) {
  physicsWorld.castRay(origin, translation, callback, filter: filter);
}