shapeCast method

PhysicsHit3D? shapeCast(
  1. Shape3D shape,
  2. Vector3 position,
  3. Quaternion rotation,
  4. Vector3 direction, {
  5. double maxDistance = 1000,
  6. int layerMask = 0xFFFF,
  7. Entity? ignore,
  8. bool includeSensors = false,
})

The first thing shape swept from position and rotation along direction hits within maxDistance, or null.

Implementation

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