Forum rules - please read before posting.

Pathfinding causes game to freeze...

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 > B) 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.

image

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

  • Some performance improvements are going to be introduced to 2D pathfinding.  If you set Character Evasion (in the NavMesh's Inspector) to None, then it will make use of caching to reduce the number of calculations needed per-path.  There will also be an accuracy slider that you can adjust: lower values bringing better efficiency.
  • Thank you, I'll give that a go! For anyone else reading, I also had some promising results in terms of speed from Unity's navmesh baking system
  • To be clear: this is an upcoming feature of v1.51.
  • 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.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.