Minor tweak to flying pathfindng starting location
authorLiza Carvelli <liza@carvel.li>
Wed, 27 Nov 2024 20:26:54 +0000 (21:26 +0100)
committerLiza Carvelli <liza@carvel.li>
Wed, 27 Nov 2024 20:26:54 +0000 (21:26 +0100)
Questionable/Controller/MovementController.cs

index e41b8f04b8523bac715bccf24a7bd89ba0ee0cd3..cc8012cf675d6734bd1ac94d5ed5af7f86d5f592 100644 (file)
@@ -317,6 +317,13 @@ internal sealed class MovementController : IDisposable
             _logger.LogInformation("Using modified start position for flying pathfinding: {StartPosition}",
                 startPosition.ToString("G", CultureInfo.InvariantCulture));
         }
+        else if (fly)
+        {
+            // other positions have a (lesser) chance of starting from underground too, in which case pathfinding takes
+            // >10 seconds and gets stuck trying to go through the ground.
+            // only for flying; as walking uses a different algorithm
+            startPosition = startPosition with { Y = startPosition.Y + 0.2f };
+        }
 
         _pathfindTask =
             _navmeshIpc.Pathfind(startPosition, to, fly, _cancellationTokenSource.Token);