Navmesh Agent Issues (RTS-Multiplayer)


I have just finished the new Multi-player RTS tutorial and the only problem I am having is with my NavMesh Agents. When I select a unit and start clicking to tell him to walk somewhere, he ignores most of my clicks. This is what I am seeing:

  • The unit spawns at a height of 1.083333 on the Y-axis. (I’ve narrowed this down to NavMeshAgent by removing any movement the unit makes while spawning, and disabling)
  • Unit is set at (Y-Axis) 1f upon spawn, NavMesh changes this.
  • Unit can move in a section of the NavMesh, but it takes numerous forceful clicks to get him to move to another section of NavMesh.
  • My terrain matches the creators. I have tried with just a cube as the terrain and the terrain provided by Unity that we downloaded.
  • I have confirmed the unit has a Complete path.
  • I have confirmed that I am telling the unit to move to a spot on the terrain and I am not click on some unseen canvas.

Here is a screenshot:

The tank moves just fine in the highlighted navmesh area, but hits a wall when moving to another triangle area unless I SPAM click and then he’ll find a path to that location.

I’ve scoured the web and I am seeing people with my same issue and unanswered spots. I think the NavMeshAgent is not sitting on the NavMesh, even though I’ve confirmed that the Prefab Y-Axis is set to zero, and that the agent base y offset was set to 0f.

Would it be worth it to purchase some sort of A* Pathfinding package on Unity’s Marketplace? I have combed through all the prefabs and the bit of code we use, and tried tweaking out the NavMesh (re-baking, trying advanced options). it seems like it can be very finnicky, wonder if I should try something else?

So while re-reading my code I did find a bug that I had yet to seek out. When we created the logic to stop the tanks from fighting over their destination. I had missed a ‘!’. I fixed it and lo & behold everything is working just beautifully now. I’ve even switched back my fancy terrain.

For those who were curious, my problem was actually not necessarily with the NavMesh configuration, but with this method:

This issue is resolved.

(if (!agent.hasPath) { return; } was the culprit as it was missing the !)

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms