So right now I’m trying to set up a turn based combat system, and I need to make a list for turn order. I have a list set up which is supposed to store a class called AgentInit. However, nothing is being stored in the list.
var initiative = new List.<AgentInit>();
for (var g : int = 0; g < enemyList.length; g++) {
initiative.Add (new AgentInit (enemyList[g].GetComponent(AgentStats).speed, enemyList[g]));
print(enemyList[g].GetComponent(AgentStats).agentName);
}
for (var h : int = 0; h < playerList.length; h++) {
initiative.Add (new AgentInit (playerList<mark>.GetComponent(AgentStats).speed, playerList<mark>));</mark></mark>
print(enemyList.GetComponent(AgentStats).agentName);
}
initiative.Sort();
That is the section of code which should be adding the objects to the list. Those lines that say to print work perfectly fine, and I’ve looked all over and have no clue what the problem is. (BTW the two variables stored in AgentInit are an int and a GameObject)
I’m not super experienced with code, any help is appreciated.