Hello! I'm not sure if this is just an Adventure Creator thing, or a Unity thing more broadly. I've implemented a navmesh into my scene, and the character will walk to the target point when the player clicks, as expected. However, it appears that when there are a couple of corners that need turning, the game freezes for a moment as calculations are made. Wandering around inside a room works as expected, but a more complex route (A >
causes the pauses. Oops, the letter A appears to have been absorbed into the wall at the top, but I think the picture is straightforward enough. Orange is the navmesh.
Usually, after a moment's thought, it'll decide to take the blue route to the target. Once in a while, it'll choose to try and walk through the wall (red route).
Bringing the pathfinding update time down to zero has stopped the pauses reoccurring as the character walks to the destination, but I think I've a couple of particular questions here:
- Are there any other measures I can use to further reduce the length of the time it takes to think?
- Is there a particular logic I should be following to the shape of the navmesh?
- Is there anything I can do to stop the characters deciding to try to cross the empty voids?
Many thanks for your help!
Comments
FYI I just ran into this on the current version 1.76.1.
Had a more complicated/larger nav mesh in a second room. There was a noticeable pause/hitch before pathing would take place when you clicked farther away on the screen to path. Tried many things until I stumbled upon this thread.
"If you set Character Evasion (in the NavMesh's Inspector) to None"
This was the solution, 6 years and a lot of versions later. Doesn't bother me as I really don't need it for a 2D game but...
Thanks for the feedback, @GeorgeBroussard.
There have been improvements under-the-hood to the default 2D pathfinding since this thread, but a separate 2D pathfinding algorithm is available on AC's Downloads page.
The "A* 2D Pathfinding" package provides an implementation of the popular A* pathfinding algorithm, and would be worth trying out if you have a particularly complex NavMesh that has a noticable lag when moving.