How can I prevent crashes when jumping with a navmesh?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DamonR

The project I have been working on (just for fun) crashes whenever the player moves too far away from navmeshes, or when jumping over enemies.

The enemies currently use navmeshes (scripts adapted from the demo project) to follow targets (such as the player), and switch to a more direct follow code when within a certain range.

I have tried modifying the navigation follow code in different ways, but have had no success so far.

The problem appears to be caused by the separation of the player from the navmesh, either when the player jumps (something I would like to keep while also having navmeshes), or when the player leaves the navmesh area (could be solved by extending the navmesh, but not ideal for areas that enemies should not be able to go).

A small reproduction project can be found here:

And the whole project can be found here:

Does anyone know how to implement a player jump system that doesn’t crash when being followed by enemies that use navmeshes?

Any help is appreciated.

Adding timers to limit the number of times a second that enemies try to recalculate paths to a moving target seems to have solved the problem.

posting from my phone#
I have figured out a way around the issue by using timers to set when to calculate the enemy movement. I have tested with a single enemy unit, and will test more tomorrow (UK time, so its half 1 in the morning).
I think the problem may not have been with the navmesh, but with my code trying to calculate too often. If it works well after testing tomorrow, I will mark the question answered and update the examples.

DamonR | 2019-06-25 00:40

:bust_in_silhouette: Reply From: DamonR

I added timers to limit the number of times a second that the path to a target is recalculated. This appears to have solved the issues I was having.
I have updated the reproduction project to include the changes made (in case it is of use to anyone), but have not yet updated my main project (as I have other parts to work on still).

I have updated the main branch on Github after recovering some of the scripts after a windows crash made the original Godot files inaccessible.