I am getting an Exception “Axis-aligned connection not found” it is coming from Pathfinding.PathTracer.RemoveGridPathDiagonals. The first time I encountered it was when I wrote a function to slow down soldiers if one of them falls too far behind the formation. It was calling the exception every frame, so I removed it. Then I tried shortening the distance between waypoints and it threw the exception every time a point needed recalculation, and the following soldiers stopped moving. What is this exception about?
Everything I can think of to get the formation working is throwing this error.
here is the code that first caused it:
void TeamMemberSpacing()
{
if (Vector3.Distance(teamMembers[0].transform.position, teamMembers[3].transform.position) > 8.49f)
{
teamMemberScripts[0].path.maxSpeed = 3 * (8.485f / Vector3.Distance(teamMembers[0].transform.position, teamMembers[3].transform.position));
}
if (Vector3.Distance(teamMembers[0].transform.position, teamMembers[2].transform.position) > 4.25f)
{
teamMemberScripts[0].path.maxSpeed = 3 * (4.242f / Vector3.Distance(teamMembers[0].transform.position, teamMembers[2].transform.position));
}
if (Vector3.Distance(teamMembers[0].transform.position, teamMembers[1].transform.position) > 4.25f)
{
teamMemberScripts[0].path.maxSpeed = 3 * (4.242f / Vector3.Distance(teamMembers[0].transform.position, teamMembers[1].transform.position));
}
if (Vector3.Distance(teamMembers[0].transform.position, teamMembers[1].transform.position) < 4.23f)
{
teamMemberScripts[1].path.maxSpeed = 3 * (Vector3.Distance(teamMembers[0].transform.position, teamMembers[1].transform.position) / 4.242f);
}
if (Vector3.Distance(teamMembers[0].transform.position, teamMembers[2].transform.position) < 4.23f)
{
teamMemberScripts[2].path.maxSpeed = 3 * (Vector3.Distance(teamMembers[0].transform.position, teamMembers[2].transform.position) / 4.242f);
}
if (Vector3.Distance(teamMembers[0].transform.position, teamMembers[3].transform.position) < 8.48f)
{
teamMemberScripts[3].path.maxSpeed = 3 * (Vector3.Distance(teamMembers[0].transform.position, teamMembers[3].transform.position) / 8.485f);
}
}
Here is the second change that caused it:
void MovementDirector()
{
moving = true;
teamMemberScripts[0].StartCoroutine(“MoveToRallyPoint”, rallyPoint);
var buffer = new List();
path.GetRemainingPath(buffer, out bool stale);
Debug.Log("buffer 0: " + buffer[0]);
Debug.Log("buffer 1: " + buffer[1]);
Vector3 nextPoint;
if (Vector3.Distance(buffer[0], buffer[1]) > 0.5f)
{
if (Vector3.Distance(buffer[0], buffer[1]) < 4f)
{
nextPoint = buffer[1];
Debug.Log(“using the buffer”);
}
else
{
direction = buffer[1] - teamMembers[0].transform.position; //
normalizedDirection = direction.normalized;
Vector3 offSet = new Vector3(normalizedDirection.x * 4, 0, normalizedDirection.z * 4);
nextPoint = teamMembers[0].transform.position + offSet;
Debug.Log(“using the 8gu calc from buffer”);
}
}
else if (Vector3.Distance(teamMembers[0].transform.position, rallyPoint) < 4f)
{
nextPoint = rallyPoint;
Debug.Log(“using the rallyPoint”);
}
else
{
direction = rallyPoint - teamMembers[0].transform.position; //
normalizedDirection = direction.normalized;
Vector3 offSet = new Vector3(normalizedDirection.x * 4, 0, normalizedDirection.z * 4);
nextPoint = teamMembers[0].transform.position + offSet;
Debug.Log(“using the 8gu calc from rallypoint”);
}
direction = nextPoint - teamMembers[0].transform.position; // duplicate
normalizedDirection = direction.normalized;
StartCoroutine(“TurnUnit”, nextPoint);
}
here is a video:
Hello,
when the pathfinding algorithm can’t find a valid path that aligns with the grid. This often happens when modifications disrupt the expected grid alignment. Make sure your grid and waypoints are correctly configured and avoid excessive recalculations that may misalign the path. Check the grid setup and ensure waypoints are placed accurately to prevent this error.
This brings up the question again of weather the Grid graph is right for my game. The only reason I choose the grid graph is because Aaron said it was the best for undulating terrain. I told him my game was not a node movement game. He said that does not matter but the path finder is trying to line things up with the grid. Another thing I have noticed is the error starts as my soldiers descend from one little sample hill, and grid graph was recommended for undulating terrain.
Would this be less of a problem on a different type of graph?