I finally bought the pro version, and I want to implement this feature. Can anyone help out?
public virtual void set_move_wall(Vector3 center, Vector3 pos1, Vector3 pos2)
{
attack_target = null;
should_shoot = false;
distractable = false;
StartCoroutine(reset_distractable(1f));
attack_mode = false;
complete = false;
move_target.GetComponent<SpriteRenderer>().enabled = show_targets;
currentWaypoint = 0;
distraction_target = null;
move_target.transform.rotation = new Quaternion();
move_target.transform.position = center;
Vector3[] endPoints = new Vector3[2];
endPoints[0] = pos1;
endPoints[1] = pos2;
this.gameObject.GetComponent<Pathfinding.Seeker>().StartMultiTargetPath(this.transform.position, endPoints, false, OnPathComplete);
}
public void OnPathComplete(Path p)
{
Debug.Log("Got Callback");
if (p.error)
{
Debug.Log("Ouch, the path returned an error\nError: " + p.errorLog);
return;
}
MultiTargetPath mp = p as MultiTargetPath;
if (mp == null)
{
Debug.LogError("The Path was no MultiTargetPath");
return;
}
// All paths
List<Vector3>[] paths = mp.vectorPaths;
for (int i = 0; i < paths.Length; i++)
{
// Plot path i
List<Vector3> path = paths[i];
if (path == null)
{
Debug.Log("Path number " + i + " could not be found");
continue;
}
var color = AstarMath.IntToColor(i, 0.5F);
for (int j = 0; j < path.Count - 1; j++)
{
// Plot segment j to j+1 with a nice color got from Pathfinding.AstarMath.IntToColor
Debug.DrawLine(path[j], path[j + 1], color, 10);
}
}
}
Is what I’m doing right now… where basically I have a wall, inside of a maze, and if the player selects the wall (cursor as position pos), I want to make two perpendicular points a little bit to the left and right (pos1, and pos2), then run to figure out which one is shorter and send the guy there.
I run the same code on 6 different guys simultaneously, who are all grouped relatively close together.
Unfortunately, between 1-3 of the 6, almost without fail, throw a “Path number 0 could not be found” or “Path number 1 could not be found” and it produces no motion for that actor.
I don’t understand at all what is going wrong here.
found the issue. I manually handle pathing becuase I run a bunch of different boid things going on, and the issue was with the “path_complete”, so all I needed to do is add “path_complete = false” to the OnPathComplete callback.