Hia
I have a large area I want AI characters to navigate. In the middle of this is a huge door that is closed at the start of the level but may or may not open during the course of the level.
Now, when I build my nav mesh setting the doors to navigation static, this results in the enemy chasing me until I get to the door and then just stopping and staring at me before going back on patrol because the navmesh doesn’t allow for him to go through the gate…
On the flip side of the coin, if I don’t mark the doors as navigation static then the nav mesh DOES allow for the enemy to pass through the gate but now, even though the gate it closed and the box collider prevents me from going through the closed gate, the enemy can pass through the solid gate like ghosts… They have capsule colliders on them and if I jump and land on one of them I can actually stand on their heads so their colliders are active and not set to be triggers… but when the navigation system tells them to go to point X, they move straight through solid objects to get there…
Okay, so, now comes the question… how do I stop this?
I understand the whole point of generating the nav mesh in the first place is for the game to know “This place is reachable and this place is not because there is something in the way. Go around it” I get that… Do does this mean that a navmesh can only be used in scenes where there is absolutely no dynamic content in the scene?
I.e. if I create the nav mesh and later have a building explode, covering the path with debree and blocking it completely… what if a stubborn ox walks in front of a passage and stops to eat some hay? Or in this case, what if I have a does I want the AI enemy to go through but only if the door is actually open.
Is the only way to do this by saying “If the path is blocked, don’t tell the enemy to go to the other side” or must I recreate the nav mesh at runtime?
The “do the logic in code so they don’t try and go to there” approach won’t work cause I have many enemies, all of them all over the place and they can try to approach the player from any direction and from both sides of the gate (since my character can actually climb over walls to unlock the gate from the inside) and once one sees me, he raises the alarm and then all the enemies come after me… even those behind other walls/gates/buildings… adding custom logic to each enemy based on his path and the location of the path and the various gates throughout the level… it’s just not practical… but as far as I am aware, neither is recreating the nav mesh every time I open or close a door…
So how do I prevent an enemy with a collider from moving through solid objects when controlled by navigation?
Thanks in advance