0 votes

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:
https://github.com/DamonRaziel/NavMeshReproduction

And the whole project can be found here:
https://github.com/DamonRaziel/Project-Bob-s-Quest/tree/master

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.

Edit#
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.

in Engine by (106 points)
edited by

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.

1 Answer

0 votes
Best answer

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.

by (106 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.