raycastAll abstract method
Casts rays uniformly between startAngle
to startAngle
+sweepAngle
from the given origin
and returns all hitboxes and intersection points
the rays hit.
numberOfRays
is the number of rays that should be casted.
maxDistance
can be provided to limit the raycasts to only return hits
within this distance from the ray origin.
If the rays
argument is provided its Ray2s are populated with the rays
needed to perform the operation.
If there are less objects in rays
than the operation requires, the
missing Ray2 objects will be created and added to rays
.
You can provide a hitboxFilter
callback to define which hitboxes
to consider and which to ignore. This callback will be called with
every prospective hitbox, and only if the callback returns true
will the hitbox be considered. Otherwise, the ray will go straight
through it. One common use case is ignoring the component that is
shooting the ray.
If you have a list of hitboxes to ignore in advance,
you can provide them via the ignoreHitboxes
argument.
If out
is provided the RaycastResults in that list be modified and
returned with the result. If there are less objects in out
than the
result requires, the missing RaycastResult objects will be created.
Implementation
List<RaycastResult<T>> raycastAll(
Vector2 origin, {
required int numberOfRays,
double startAngle = 0,
double sweepAngle = tau,
double? maxDistance,
List<Ray2>? rays,
bool Function(T candidate)? hitboxFilter,
List<T>? ignoreHitboxes,
List<RaycastResult<T>>? out,
});