Hello All
I’m having a fairly hard time understanding how to add modifier volumes to prefabs for different agents.
I have roads in my game where I want humanoid characters (Agent Type = “NPC Character”) to only walk on sidewalks and crossings, and vehicles (Agent Type = “Road Vehicle”) to only move on the road surface.
My prefabs have modifier volumes set to “Not Walkable” for people, and modifier volumes set to “Walkable” for cars. These volumes are identical (I copied the Component and Pasted as a New Component) with the exception of the area type and affected agents:
Which results in the “overlapping” navmesh modifiers here:
I then have two NavMeshSurface components on my ground plane, one where the people agent is set to Walkable, and another where cars are set to Not Walkable:
The road prefab is then instantiated and placed around when loading the level and both navmeshes are recalculated after all objects have been placed:
npcSurface.BuildNavMesh();
vehicleSurface.BuildNavMesh();
And this is where things start getting weird…
Everything works for the people in the scene, and they only move where they’re supposed to. But as soon as I spawn a vehicle, I get the dreaded “SetDestination can only be called on an active agent that is on a NavMesh” error.
I’ve been stuck on this for a few days trying different ideas. Short of creating yet another ground plane to hold the road vehicle surface, and duplicating all of my prefabs and somehow overlapping them, I’m out of ideas here.
When I enter Play Mode and enable gizmos, I can see that the default NPC Character agents can move where they’re supposed to. Great:
However when I disable the NPC Character surface and enable the Vehicle surface, I see that nothing is walkable:
Am I missing something really simple here? Or am missing a fundamental step somewhere? Any help would be greatly appreciated!