So I’m a little new to NavMeshs.
Anyway, I’m trying to make paths on the nav mesh sometimes not be available.
The situation is we have a horror game with monsters. These monsters can not open doors, however the player can. Once the player opens a door, the monster can obviously go through. However, if the door is closed, they shouldn’t consider the door a viable path.
With the experiments I’ve tried so far, the door is not marked as static, so they seem to just ignore the door and pass through it as if it was never there.
It seems that Unity 4 will get dynamic obstacles, but until then, here’s my workaround:
Make a door, and add a NavMeshAgent to it. Then, I have a script that keeps it rooted in place (since other agents can push it away), which can be simple as:
transform.position = new Vector3(x, transform.position.y, z);
(x and z are assigned by me, y position is decided by NavMeshAgent)
To open or close the door, just do:
gameObject.getComponent<NavMeshAgent>().enabled = true; // or false