AILerp: Getting the tag of the next node of the path

Hi,

I have been using A* for a little while now (the Pro version) and have an RTS game using unfiltered AILerp as it is the only path that loyally follows the grid exactly (this is what I want). RVO local avoidance does not produce the results I want at all (back when I was using AIPath) and so I figured that I could prevent AILerp agents from moving on-top of each other using some tag manipulation.
The goal is to never allow agents to occupy the same cells at the same time, so I use two cases:


In case 1, one unit moves and the other is stationary. When a unit ends its path (here it just reached the end, hence the leftover debug line by the car), it sets the cell it is in to Tag 3, which is unwalkable by all agents, thus the moving unit (the jeep) will correctly pathfind around it. :white_check_mark:
image
In case 2, both units move with intersecting paths. Currently units track the current cell they’re on, setting it to Tag 2. The idea is that units should check the cell they are about to move into to see if it is Tag 4 and if not, set it to Tag 4 and move into it. Thus, Tag 4 represents a cell that is claimed by a unit that is moving. When a unit detects that the cell it will move into next is already Tag 4, it should stop moving entirely and wait for the unit to clear out (meaning it waits for the cell’s tag is reset to 0). This was my theoretical method for preventing cell overlapping while moving (exactly what is happening in the picture).

The main issue here is case 2, because I do not know how to get the “next node” that the agent is going to move into next (as AstarPath.active.GetNearest(gameObject.transform.position) will get the current cell, but I have to check the next). I scanned the forum already, and found a similar post (Getting the next node in a path) but I don’t understand at all how to implement it. If you could help with any method for getting the next cell with the AILerp script that would help me implement case 2. I suppose if there was an entirely different way to implement case 2, I would be interested, but it seems like it would work if I could simply reliably get the next cell.

Thank you for your time.

Hi
seeker.GetCurrentPath().path stores the current path list, but if you are using modifier, below code may not work.

var pathList = seeker.GetCurrentPath().path;
var currentNode = AstarPath.active.GetNearest(gameObject.transform.position);
var currentIndex = pathList.IndexOf(currentNode);
var nextNode = pathList[currentIndex + 1];