So I recently came across a problem while working on my FPS game's enemies: they didn't seem to be able to traverse up a sloped surface using a navmesh. For anyone with a similar issue, here's a solution (because I didn't find any existing resources on this for Godot 3.5+): don't apply gravity to your enemies. This allows them to freely navigate the mesh without fighting back against an external force. Don't worry about them floating, either, because they appear to snap to the navmesh and stay on the ground. Many of you have most likely figured this out already, but I wanted to put this finding out there for anyone like me who might've been puzzled by this and could use this post to get them out of a block!

Happy Programming!

  • Amon replied to this.

    BabaT130 Thanks for the heads up. Noted for future projects.

    Another point to make when it comes to navmesh agents on slopes in general, make sure that whatever mesh they're travelling on is smooth and has nothing like a vertex poking up, I have found that dramatically interferes with the agent behaviour. The pathfinding will calculate correctly, but it won't take into account small bumps like that, so the agent will blindly walk into it and get itself trapped, yes I'm aware of the being able to kind of nudge it out of the way with some code if it gets stuck but that doesn't always work. Better option is prevention and to make sure your walkable meshes are smooth surfaces.

    This one caught me out pretty badly so I thought I'd mention in case anyone is struggling because I found it odd the agents worked perfectly on flat planes but not sloping hills etc. I feel like a lot of tutorial makers don't go into this and cheat a lot when they're doing "Do this" tutorials and only ever do their navmeshes on a flat plane because that is not what most game devs are going to have to deal with in real world scenarios.

    Also if you're dealing with some sort of custom terrain, if you click mesh and then generate navigation mesh in the drop down menu it will generate a much more accurate mesh than what you get if you generate the navmesh the normal way for some odd reason.

      13 days later

      Lethn When you generate navigation mesh in the mesh drop down menu all you are doing is copying the vertices and polygons from a Mesh Resouce to a NavigationMesh resource. When you generate a navigation mesh "the normal way", which properly you mean using the NavigationRegion3D / NavigationMeshInstance baking drop down, you are actually parsing the SceneTree nodes and objects as the source geometry for the navigation mesh baking.

        smix8 Would you mind explaining in more detail how to do that through the normal baking? I tried messing around with it a bit but I've only been able to do it through the mesh drop down menu, this is quite an important detail that I don't see explained anywhere and has been a big source of frustration for me when debugging navmesh agents. Please bear in mind as well that I have some quite extreme slopes and hills on my mesh and that's all been on purpose, I also quite like the cartoony aesthetic of the hills as well.