Generation navmesh in real time

Hi guys.

Please forgive my english.

Tell me if it is possible to generate navmesh in real time on some area of terrain.
It is very important that navmesh covers a specific area, not the entire terrain.

Thanks for your time and your answers.

P.S. I’m from Russia and maybe you can suggest the appropriate literature in Russian? But if not, everything is in order, reading in English will be useful.

4380421--397624--2.png

The way I solved this in unity a few years ago was simply to put a subdivided plane (low poly mesh) down and raycast the verts downward so the low poly mesh loosely hugged the terrain, It does not need to be perfect for a navmesh. Then just bake that…

There might be better ways but it had no drawbacks.

1 Like

@hippocoder , thanks for your quick reply!

Unfortunately, my knowledge of English does not allow me to fully understand your answer. Let me clarify, should I create a plane and cast rays from its edges to TERRAIN? then bake NAVEMESH on the resulting surface?

If my assumption is correct, I cannot understand how I can create a curved surface by throwing rays from the vertices of the plane.

For this approach you are not baking terrain. you are baking small meshes in a similar shape of the terrain. To do this you create a mesh and bake that, not terrain.

You move the verts of the plane mesh to the ground, and you find where the ground is by raycasting down at each mesh point.

A simple tool will do this, or you can write a simple script to move the verts of the mesh to raycast hit points.

Do you need help moving mesh verts in code?

1 Like

they had some runtime baking tools here also,
can generate nav mesh based on volume area and so on,
https://github.com/Unity-Technologies/NavMeshComponents

example

1 Like

@hippocoder , thank you! It seems now I understood what you meant. I hope my knowledge is enough to do it.

@mgear , thanks! I will watch this video soon. After reviewing it in fast rewind, it seemed to me that this should work.

In any case, I will try to make both options to see what will work faster.

@hippocoder

I think that first I should try to do it myself. But if I fail to do this, I will turn to you for help. Thanks for offering help.

generate navmesh by volume area seems easier if possible try that first, I thought to mention it but forgot in my rush :stuck_out_tongue:

1 Like

@hippocoder , @mgear

Hi, it’s me again.

I took the time to work on my project. When I tried to add scripts from the github repository “Unity-Technologies / NavMeshComponents” I received the error "Assets / Borrow / NavMeshComponents / Scripts / NavMeshSurface.cs (16.6): error CS0246: found. Are you missing an assembly reference? ". I could not understand the reason for this error, but I found its solution here "The type or namespace name `NavMeshSurface' could not be found. - Unity Engine - Unity Discussions / ".

The problem has already been solved, but I would like to know the reason for its appearance. To prevent this error from occurring again. Maybe you have time to help with this?

Thanks.