Don’t know if this is the right sub-forum, but I couldn’t find a more fitting one
I’ve got some question about NavMeshes:
Is it possible to give areas a cost-multiplier that can vary from agent to agent?
For example: There’s a bandit camp. The camp itself is not an actual obstacle, but moving through it is risky and should only be attempted when the way around is much, much longer. That means I don’t want an all-or-nothing decision like “only go there when there is NO other way at all”, but an economical decision like “only go there when the time saved justifies the risk”. And I also need the area-cost to be selectively applicable, because a bandit doesn’t care if he has to cross his own camp.
A recast-NavMesh updates in the background without slowing down the simulation. But is it possible to change this behavior and make the NavMesh do all necessary updates at once, freezing the simulation in the meantime? This would be very useful after procedurally placing large objects in a level, or even building a level procedurally from nothing.
I have read that NavMeshes for moving geomtry like platforms was high on the priority list (link). So, is it possible now? I can’t find a way to prevent the NavMesh from constantly updating when objects are moving.
What if I have some sort of fire elemental that is immune to fire and a lava surface that should be marked as an obstacle for most units but not for the fire elemental? Is that possible at least?
You will have more luck on the C++ forums for implementation specifics like this.
As for your question number 1. You can tag areas as “unfavorable” to navigate through. To do this, make a actor blueprint with just a box volume and add a “NavModifier” component. In there you can configure how agents would consider/assign cost to the area while navigating. For any actor with a NavModifier, the navigation mesh will construct a bounding box around it. That box is the affected area. I’m pretty sure you can make some nav modifiers only affect some agents but I’m not sure of the specifics.
How do I have agents consider area cost? All I see is 4 types of NavMesh modifiers to choose from and none of them is described as having a “cost”. The closest thing is the obstacle-modifier, but since it only gets traversed when there is no other way, it doesn’t help me in the scenario I described.
Create a new bp from class “NavArea”, call it “navArea_banditCamp” for example
-> inside the blueprint set the travel costs to higher than 0 ( play with the values to see what works best for you )
( alternative you can also override the travel costs in the nav query filter )
Create a new bp from class “NavigationQueryFilter” call it “navQuery_avoidBanditCamp”
-> inside the bp add 3 Areas: “Default”, “Null” and “navArea_banditCamp” for "NavArea_Null set “is excluded” to true ( to completely disable navigation in that area )
Place your NavModifier for the bandit camp in the level and under default set the “Area Class” to “navArea_banditCamp”
Now when you call “Move To Location” or “Move To Actor” to tell your non-bandits where to move select “navQuery_avoidBanditCamp” as the filter class and they will avoid all areas that are marked as “navArea_banditCamp”