- Home /
Any way to set NavMeshAgent.walkableMask in script with more than 7 user layers?
Hi,
I have up to 9 NavMeshAgents in a scene. On my NavMesh, each agent walks on a base layer, and one other layer which is specific to that agent, giving each agent a part of the NavMesh which only they can traverse.
My problem comes when trying to apply the NavMeshAgent.walkableMask in script, which needs to be set as a bitmask. Layers 10 and above become impossible to apply in script due to hitting the int ceiling.
For example adding layers 3 & 0 to the layer mask:
Layer 3 = 8, Layer 0 = 1, therefore 8 + 1 = 9, in binary = 1001
navMeshAgent.walkableMask = 1001;
This is fine, but when we reach layer 10 things get a bit tricky:
Layer 10 = 1024, Layer 0 = 1, therefore 1024 + 1 = 1025, in binary = 10000000001
navMeshAgent.walkableMask = 10000000001;
The problem is that 10000000001 is too large for an int, but WalkableMask needs to take an int as a bitmask.
So how does one go about adding a combination layer mask for anything higher than layer 9?
Thanks, Woody
Your answer
Follow this Question
Related Questions
Can I find the layer of a NavMeshPath corner? 0 Answers
NavMeshAgent animation - sliding 2 Answers
How to prevent NavMeshAgents from teleporting to the other NavMesh when crossing OffMeshLinks? 0 Answers
Pathing multipe agents to a single rally point with navmesh? 1 Answer
Navmesh Agent Path Not Updating 1 Answer