Skip to content

Commit

Permalink
Elpis navigation fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
awgil committed Feb 22, 2024
1 parent 3067230 commit 02a78ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion vnavmesh/Movement/FollowPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class FollowPath : IDisposable

private NavmeshManager _manager;
private NavmeshQuery? _query;
private bool _flying;
private List<Vector3> _waypoints = new();
private OverrideCamera _camera = new();
private OverrideMovement _movement = new();
Expand Down Expand Up @@ -43,7 +44,9 @@ public unsafe void Update()
while (_waypoints.Count > 0)
{
var toNext = _waypoints[0] - player.Position;
if (new Vector2(toNext.X, toNext.Z).LengthSquared() > Tolerance * Tolerance)
if (!_flying)
toNext.Y = 0;
if (toNext.LengthSquared() > Tolerance * Tolerance)
break;
_waypoints.RemoveAt(0);
}
Expand All @@ -70,6 +73,7 @@ public void MoveTo(Vector3 destination)
if (player == null || _query == null)
return;
_waypoints = _query.PathfindMesh(player.Position, destination, UseRaycasts, UseStringPulling);
_flying = false;
}

public void FlyTo(Vector3 destination)
Expand All @@ -78,6 +82,7 @@ public void FlyTo(Vector3 destination)
if (player == null || _query == null)
return;
_waypoints = _query.PathfindVolume(player.Position, destination, UseRaycasts, UseStringPulling);
_flying = true;
}

public void Stop() => _waypoints.Clear();
Expand Down
2 changes: 1 addition & 1 deletion vnavmesh/NavVolume/VoxelPathfind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public bool ExecuteStep()
return true;
}

public void Execute(int maxSteps = 20000)
public void Execute(int maxSteps = 1000000)
{
while (maxSteps-- > 0 && ExecuteStep())
;
Expand Down

0 comments on commit 02a78ca

Please sign in to comment.