0 votes

Hello -

I recently changed my top down game from 2d to 3d, which went pretty smoothly as nearly all the code could stay the same. The one exception to this is the navigation. When it was in 2d, I made a script to update the navigation polygon whenever a new thing that needed to be avoided was added. The script was fast, and worked pretty well.

I would like to be able to use this same script, or something similar, to update the 3d navmesh as well, but I wasn't able to find any way to do this. I did find a way to turn a navigation polygon into a navmesh with get_mesh(), but was unsuccessful at actually using the resulting mesh.

Is it possible to manually make and set a navigation mesh?

Thanks!

Godot version 4.0 beta 3
in Engine by (18 points)

Update - I have been able to set the navmesh with either addpolygon or createfrommesh. However, I am still having problems with both of these methods. The first is that the navigation Agent seems to get stuck on some of the edges between triangles, and the second is that the navmesh doesn't show in game even if the shownavigation debug option is turned on.

1 Answer

0 votes

NavigationAgent get stuck on edges when the desired distances are set to small compared to the agent speed. In that case the agent always overshoots the next path point (which is on the edge) and dances back and forth.

If you only change the internals of a NavigationMesh the debug display will not update. You need to use setnavigationmesh() with a different NavigationMesh or set it to null first before readding the changed NavigationMesh.

by (102 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.