Problem getting player to switch navmesh layers

Alright so I have a character and my navmesh is set up into two layers. Default which the player can always walk on and phase (user layer 0) which the player cannot walk on usually. What I want to do is let the player use an ability that allows him to walk on the phase areas of the navmesh. There doesn’t seem to be any documentation on how to do this anywhere so I have come here to see if you guys know the answer. The closest I got was:

Agent.walkableMask.Equals(9);

Agent is a reference to the players NavMeshAgent. From what I understand this should let the player walk on the default layer and user layer 0 (phase) but it has no effect at all and I get no error messages after compiling or in game. What’s the correct way to do this?

You need to provide a proper layer number as input.

Read the answer to this question: NavMesh WalkableMask

This will tell you how to select the proper layer to provide as input to the WalkableMask.

You set is as:

Agent.walkableMask = 9;

Setting it to

Agent.walkableMask.Equals(9);

will just make a comparison and not actually set it.