- Home /
NavMeshAgent following road (even if slightly longer path)
Hey all!
I have a basic scene with a plane as a ground and another thinner plane sitting on top of the ground that is acting as the road.
How would I make the NavMeshAgent follow the road rather than walk on the regular ground? I know if the Agent follows the road it will have a longer path, however, this is desired.
Things I've tried and their results:
Set ground on NavMeshLayer with cost of 1 and road on seperate NavMeshLayer with cast of 0.5 (no difference in path)
Same as above but changed road layer's cost to 5 (just a test to see what happens). Agent purposefully avoids road
Same as above but set Ground layer's cost a large number (10) and road's cost to a negative number (-10). No difference in path.
Could the problem be that the road object is sitting on top of the ground? In other words: 2 layers overlapping? If this is the problem how would we overcome this?
why789
Answer by LukaKotar · May 11, 2012 at 04:55 PM
You should go into Window > Navigation, then select the plane under the road, and select Not Walkable in the Navigation panel. Mess around with the settings to get the result you want.
And don't forget to bake your scene with the Bake button at the bottom ;)
Won't work.
The plane that's sitting under the road is the same plane that the player walks on (it's the ground).
So... If I set the ground as unwalkable I won't get too far.. hehe
Then create a new layer for the ground, set the ground to the layer you just created, and on the Nav$$anonymous$$eshAgent, select this layer to not walkable only for the Nav$$anonymous$$eshAgents you want.
If I understand your question correctly...
@Luka$$anonymous$$otar No I don't think you understand...
I have the ground on the ground layer. The agents need to be able to walk on the ground layer (it's the ground...)
I have a plane sitting on top of the ground that represents the road.
How would I make the agent walk on the road if possible. The agent should still be able to walk on the ground, however, the road should have a higher priority, thus causing the agent to take a slightly longer path in order to follow the road to get to the destination.