how to change navmesh agent Area mask through code?

I need to change the area mask of my navmesh agent through code at runtime, to allow my agent to move to different areas of the map. How is this done through code? For example, I need to change the Nav mesh agent’s area mask from “walkable” to “everything”. Thanks.

ex. :

agent.areaMask = NavMesh.AllAreas;

1 Like

convert layer name to layer int using NavMesh.GetAreaFromName()

2 Likes

also check this out NavMesh.SamplePosition custom area bug? - Unity Engine - Unity Discussions