message: Compute AGL and forward distance to obstacle
diff: @@ -115,7 +115,9 @@ class Vehicle {
  rotation.Yaw = FMath::RadiansToDegrees(pose.rotation[2]);
  // Get AGL
  - float agl = getDistance(0, 0, -1);
  + float agl = getAgl();
  +
  + float fwd = getFwd();
  // Check for AGL going positive
  if (!_posagl) {
  @@ -123,13 +125,13 @@ class Vehicle {
  }
  // We've returned to the ground after a positive AGL
  - if (_posagl && agl == 0) {
  + if (_posagl && agl <= 0) {
  _dynamics->stop();
  debugline("STOP");
  }
  else {
  - debugline("AGL = %3.2f m", agl);
  + debugline("AGL=%3.2f fwd=%3.2f", agl, fwd);
  }
  // Set vehicle pose in animation
  @@ -143,18 +145,18 @@ class Vehicle {
  // Animation effects (sound, spinning props)
  + // Returns distance to collision with nearest mesh in a cardinal direction, or -1 if none encountered.
  // See https://unrealcpp.com/line-trace-on-tick/
  - float getDistance(int8_t dx, int8_t dy, int8_t dz)
  +
  + float getAgl(void)
  {
  // Start at a point on the surface of the sphere enclosing the vehicle
  FVector startPoint = _pawn->GetActorLocation();
  - startPoint.X += dx * _vehicleSize;
  - startPoint.X += dy * _vehicleSize;
  - startPoint.Z += dz * _vehicleSize;
  + startPoint.Z -= _vehicleSize;
  // End at a point far from the sphere
  float d = 1e6;
  - FVector endPoint = FVector(startPoint.X+dx*d, startPoint.Y+dy*d, startPoint.Z+dz*d);
  + FVector endPoint = FVector(startPoint.X, startPoint.Y, startPoint.Z-d);
  //DrawDebugLine(_pawn->GetWorld(), startPoint, endPoint, FColor::Green, false, 1, 0, 0.5);
  @@ -168,7 +170,34 @@ class Vehicle {
  }
  }
  - return 0;
  + // No collision
  + return -1;
  + }
  +
  + float getFwd(void)
  + {
  + // Start at a point on the surface of the sphere enclosing the vehicle
  + FVector startPoint = _pawn->GetActorLocation();
  + startPoint.X += _vehicleSize;
  +
  + // End at a point far from the sphere
  + float d = 1e6;
  + FVector endPoint = FVector(startPoint.X+d, startPoint.Y, startPoint.Z);
  +
  + //DrawDebugLine(_pawn->GetWorld(), startPoint, endPoint, FColor::Green, false, 1, 0, 0.5);
  +
  + // Trace a ray to any other mesh
  + FHitResult OutHit;
  + FCollisionQueryParams CollisionParams;
  + if (_pawn->GetWorld()->LineTraceSingleByChannel(OutHit, startPoint, endPoint, ECC_Visibility, CollisionParams)) {
  + if(OutHit.bBlockingHit) {
  + FVector impactPoint = OutHit.ImpactPoint;
  + return (impactPoint.X-startPoint.X) / 100;
  + }
  + }
  +
  + // No collision
  + return -1;
  }
  void addAnimationEffects(void)
  