Hi,
I have a issue when using StartMultiTargetPath that does not appear when I’m using the normal StartPath. I made a tasksystem, and a unit first checks with Astar which task is closest to him.
Some tasks have a single position, for them I use “seeker.StartPath” and that works perfectly. Some have multiple positions, for them I use “seeker.StartMultiTargetPath”.
foreach (var taskValue in taskDictionary.Values.ToList())
{
if (taskValue.AccesPositionList.Count > 0)
{
var path = seeker.StartMultiTargetPath(transform.position, taskValue.AccesPositionList.ToArray(), false);
yield return StartCoroutine(path.WaitForPath());
if (path.error != true)
{
float taskDistance = path.GetTotalLength();
if (taskDistance < dist)
{
dist = taskDistance;
task = taskValue;
pos = path.originalEndPoint;
}
}
}
else
{
var path = seeker.StartPath(taskValue.TaskPosition, transform.position);
yield return StartCoroutine(path.WaitForPath());
if (path.error != true)
{
float taskDistance = path.GetTotalLength();
if (taskDistance < dist)
{
dist = taskDistance;
task = taskValue;
pos = taskValue.TaskPosition;
}
}
}
}
While “seeker.StartMultiTargetPath” does work, the downside is that the unit immediately starts moving, it does not do this with “seeker.StartPath”
Is there a reason for this? I only want the path length at this point, and not yet to move the unit.
On this script I only use
gameObject.GetComponent<Seeker>();
On another script, that handles the movement I have
gameObject.GetComponent<AIPath>();
Both are on the same GameObject though.
Thanks in advance!