Is there anyway I can set the area cost of a dynamically generated mesh?
Let’s say if I create a diamond shaped mesh during runtime. How would I set the area cost of that mesh?
Thanks in advance.
Edit:
I was able to create a quick and dirty implementation today.
VIDEO 1 (What I DO NOT want):
VIDEO 2 (What I DO want):
The problem with Video 2 is that in order to get that pink mesh (ie. the path that is less tactical to traverse through) I have to re-bake the entire scene, otherwise, the area cost of the pink mesh will not get generated.__ __Re-baking the entire scene is the least efficient thing to do.
Is there any way to generate the area cost in video 2 without having to re-bake the entire NavMesh?
Perhaps this? This will change the cost for every navmeshsurface with the same area int.
Lets say you have a navigation area type of “diamond” with a default cost of 10. I don’t think there is a way to set one area of “diamond” to 15 while other areas of “diamond” are 10. However, I believe you can set custom costs for individual agents for different areas but the above method will override those.
or perhaps maybe the answer you’re looking for is to simply set the diamond’s default area to “diamond” when you build it…
Unfortunately, this didn’t help. All it does is set the area cost, but it does not generate/build the area cost into the NavMesh. So essentially, I am getting the behavior from Video 1.
It seems I need a way to update the NavMesh so that it builds/generates this high cost area into the NavMesh at runtime. I will have to continue sifting through the docs.
Hey did you manage to do this? I have and idea that i wonder if it would work (im gonna try it on my current project when i have advanced more ).
You can have a dynamic navmesh generating in a big area around your main character for enemies to use, big enough for them not to be left behind if they are intended to keep chasing you. Around you can have a mesh that moves with you that it set to be used by the navmesh to generate dynamically, you set the cost of this area higher that the surrounding one and the enemies should tend to path around it because of its higher cost, it would kinda be like if you are walking with a puddle of water around you and enemies prefer not to cross or step in.
I haven’t looked into navmeshes in a while so i don’t remember if the area cost is set for a specific mesh or if a colliders applies it to an area, if it’s the first it would complicate thing on games that are not 2d because you would have to generate the mesh to match the surface.
Does anybody have an idea if this could work?
One idea I had played around with as mind experiment was using a terrain to mesh converter. I believe it wound be easier to set regions of the mesh with discrete values. The problem I would be tackling would be a contoured terrain, i.e. a constantly changing y- axis.