raycast method

PhysicsHit3D? raycast(
  1. Vector3 origin,
  2. Vector3 direction, {
  3. double maxDistance = 1000,
  4. int layerMask = 0xFFFF,
  5. Entity? ignore,
  6. bool includeSensors = false,
})

The first thing a ray from origin along direction hits within maxDistance, or null.

Implementation

PhysicsHit3D? raycast(
  Vector3 origin,
  Vector3 direction, {
  double maxDistance = 1000,
  int layerMask = 0xFFFF,
  Entity? ignore,
  bool includeSensors = false,
}) {
  final world = _world;
  if (world == null) return null;
  final hits = world.raycast(
    origin,
    _along(direction, maxDistance),
    filter: _filter(layerMask, ignore, includeSensors),
  );
  return hits.isEmpty ? null : _hits(hits, maxDistance).first;
}