One way navigation blockers / high weight within area in a single direction?

  • A* version: 5.3.3
  • Unity version: 6000.1.2f1

Hi, I’m looking for advice on making One-way navigation areas.

In our game, players can build and can place things like one-way signs to be able to control the flow of AI throughout their buildings. So the player can place a sign on an entrance/exit make NPCs enter a room through one direction, and leave through another.

Currently, I’ve managed to get it working using a custom traversal provider, blocking of navigation in a single direction in CanTraverse if the from and to nodes are intercepting the bounds of my One Way area in the wrong direction. However, this isn’t an ideal solution as it leads to issues if the NPCs are sent into a room with a one way sign and no exit. Ideally, I’d have been able to override GetTraversalCost in the TraversalProvider instead, adding weight in a single direction, however there is no way I’m aware of to get the previous node in GetTraversalCost, so I cant determine the direction of travel.

Any advice on a better solution or work around to this issue would be appreciated. Thanks :slight_smile:

Hi

I have good news for you! In the 5.4 beta, you CAN set the connection cost based on both the start and end node. The whole ITraversalProvider interface has been reworked quite significantly.

See ITraversalProvider - A* Pathfinding Project

and Upgrade Guide - A* Pathfinding Project

1 Like

That’s amazing thanks! Exactly what I needed. :slight_smile: