I`m trying to figure out how cycling through unit states is supposed to take place. Should the algorithm be contained in a for loop? Bellow I`m trying to get a unit head towards a new destination once it has reached its first destination. When the unit reaches its destination it stops and goes idle, this is the bit I have working. When I have several units in the scene I can`t get the same unit do a (complex) sequence of things however. i.e. they all stop at reaching the end of path and go idle but when I want one of them to automatically take off again upon reaching path end, another unit does it, not the one I intended.
//status:
// 1 walk
// 2 idle
for (int i = 0; i < UnitMaxIndex[0] + 1; i++)
{
if (Characters[i].Status == 1)
{
Arrived = FolloWPath(nms * 20, &Characters[0], i, false, 10,TheScreenLetterGroup, Characters[i].ID,&Accept[0]);
if (Arrived)
{
Characters[i].Status = 2;
ConsoleMoveUp(&amp;amp;amp;amp;amp;amp;amp;TheScreenLetterGroup[0],&Accept[0]);
StringCchPrintfA(debugmess, 27, "arrived ix %d ",i);
AddConsoleText2(debugmess,&TheScreenLetterGroup[0],&Accept[0]);
}
}
if ((Characters[i].Status == 2)&&(Characters[i].ID == 1))
{
int uniqueid = 1;
int index = i;
ResetPath(index, &Characters[0]);
FindPath( Characters[index].StartPosX , Characters[index].StartPosZ, 14, 10, &amp;amp;amp;amp;amp;amp;amp;Characters[0], index, Chart, ChartSide[0],&amp;amp;amp;amp;amp;amp;amp;TheScreenLetterGroup[0],uniqueid,&Accept[0]);
Characters[index].Status = 1;
if (animationstage == 9)
{
timecounter++;
}
if (timecounter == 10)
{
}
}
}
pseudo code to explain that mess code
FindPath(Destination1, Charcaters[0]);
for(int i=0 i < UnitCount; i++)
{
if(Characters[i].Status==1)
{
bool Arrived = FolloWPath(Characters[i]);
if(Arrived)
{
Characters[i].Status = 2;
}
}
if(Characters[i].Status==2)&&(Characters[i].ID == 0)
{
ResetPath(Characters[?]);
FindPath(Destination2,Characters[?]);
Characters[?].Status = 1;
}
}