NavMeshAgent.areaMask returns the wrong mask

I have a NavMeshAgent with a component called NavTest.

I have the NavMeshAgent components areaMask set to “Air” in the inspector.

Inside my NavTest.cs file I have just the start method with a debug.log call like this

Debug.Log(GetComponent<NavMeshAgent>().areaMask);

This results in “8” being printed to the console. This is causing me a bit of a headache as either I’m not getting something here or it’s a bug.

When I Debug with the following line I get my expected result

Debug.Log(NavMesh.GetAreaFromName("Air"));

This code returns the correct integer being 3.

My navigation and component tab looks like this:

Is this a bug or is it me not understanding something?

Replying incase anyone else makes the same mistake.

SOLVED:

It appears that NavMeshAgent.areaMask returns a bitfield which means that the return i get of 8 is actually correct. I completely missed that this returned a bitfield and clearly need to look into and understand bitfields .

4 Likes