Attention | Topic was automatically imported from the old Question2Answer platform. | |
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.
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.
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