Forum rules - please read before posting.

Pathfinding questions

Hi there,

I stumble upon it since I use AC, but lately it's becoming really strange. The pathfinding in my scenes is way off of being usable. I use the mesh collider system with NavMeshes that I build in Blender with the rest of my scene. Look at this screenshot as a reference:
image
If the player stands at position "Start" and I click to the position "End", he walks the red path to reach the aim (along the outside of the NavMesh).

Another weird situation:
image
In this situation the character walks the red path (the longest), but shouldn't he walk the blue path to reach his aim? And sometimes he just takes the straight way through the air...

I think I'm doing something wrong, does anyone have a clue to this?

PS: I am currently thinking of calling my game "The longest journey", but that could bring me into serious trouble... ;)

Yours
Marcus

Comments

  • Are all of your mesh's triangles facing the same way?  They'll all need to be facing "up".

    Try also changing your Destination accuracy slider in the Settings Manager.  If your characters are very much bigger or smaller than the demo game's character, you may need to have a different value.

    If all looks OK and you continue to have problems, there's always the option of using Unity Navigation instead.
  • MACMAC
    edited February 2016

    As I recently found out that you could have gizmos activated in the game window and the calculated path is visible there, I did some more testing and discovered some things. The behavior in the first screenshot is shown if the character walks outside of the NavMesh, which is possible due to the fact, that he is walking using root motion. It seems like he is walking around the NavMesh then to enter it somewhere else and after that walking to the point I clicked. I made a video yesterday evening to show this better, but was not able to upload it. I will try to do it when I'm home again.

    Concerning the behavior in screenshot 2: Is it possible, that the pathfinding algorithm declares the shortest path the one that leads over the minimum number of vertices instead of calculating the real lengths of the path parts? That would explain the behavior.

    I try to avoid Unity pathfinding, because I make heavy use of more than one NavMesh in my scenes (eg. a boat that comes to a landing pier and that you could walk in then).

  • If your character is leaving the NavMesh by a noticable amount, that'll be a case for increasing the Destination accuracy slider.

    The pathfinding algorithm the MeshCollider script uses is Dijkstra's, which I believe is indeed shortest path.
  • This is the video I made yesterday. The Destination accuracy is set to 1.0 since a long time (super-accurate-mode doesn't give good results). I tried to lower it stepwise down to 0.05 now and it seems to be a bit better, though it still happens that the character leaves the NavMesh. But with this setting the character ends up far away from where I have clicked on the screen. The issue has to do with the way the character movement (the root motion) is done in the walk animation. One "step" of my character is possibly too far for a single step to move. Maybe I should redo the walk animation by using half of the step distance and making it 2 times faster. Or is there a way to stop him moving half way in the walk loop, maybe?

    I took a look at the NavigationEngine_meshCollider script and it indeed takes the vector distance into account. I'll try to trick the algorithm by altering the NavMesh layout in the critical areas.
  • Are you using v1.50 or newer?  Improvements were made to the super-accurate mode.  You should have a read of Section 3.11 of the Manual, too, as it gives some tips on how to use it in conjunction with root motion.
  • Always using the latest version. I read myself into using a blend tree to scale the walking animation and it works like a charme. To get the behaviour in screenshot 1 is still possible but I have to click the right position and the right time and I have to switch gizmos on to see what I do. The chance that the later player will run into such situation is very low. And I now have a character that moves his head towards active hotspots, which looks fantastic, thanks to blend trees. And super-accurate mode is working now, too.
    I also did some additional edge slides in my NavMesh wich makes pathfinding a lot better (Screenshot 2). To keep the number of vertices to the bare minimum is possibly not the best solution for some situations.
    Once again thanks a lot for your help.
  • Forgot to say, that after using the variable walk animation speed, teleporting is no longer possible. If I teleport the character to a marker then he appears near the aim-marker but no longer at the exact position. Since I added a "Engine: Wait" action with 1 second before the teleport action it works 90% of the time but still not always.
  • Can you provide steps to recreate that problem?
  • I will try to nail down that issue and give further details.
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.