raycast method

RaycastResult<ShapeHitbox>? raycast(
  1. Vector2 direction, {
  2. Vector2? origin,
  3. double? maxDistance,
  4. Iterable<ShapeHitbox>? ignoreHitboxes,
})

Implementation

RaycastResult<ShapeHitbox>? raycast(
  Vector2 direction, {
  Vector2? origin,
  double? maxDistance,
  Iterable<ShapeHitbox>? ignoreHitboxes,
}) {
  try {
    return gameRef.raycast(
      Ray2(
        origin: origin ?? rectCollision.center.toVector2(),
        direction: direction,
      ),
      maxDistance: maxDistance,
      ignoreHitboxes: [
        ...children.query<ShapeHitbox>(),
        ..._getSensorsHitbox(),
        ...ignoreHitboxes ?? [],
      ],
    );
  } catch (e) {
    return null;
  }
}