- Home /
List not adding
I have this code. The alliances form properly, but the nation's ally lists only increase in length, and nothing is added to them
Alliance newAlliance = new Alliance();
Alliance newAlliance2 = new Alliance();
newAlliance.nation1 = nation;
newAlliance2.nation1 = newAlly;
newAlliance.nation2 = newAlly;
newAlliance2.nation1 = nation;
newAlliance.year = _TimeSystem.year;
newAlliance2.year = _TimeSystem.year;
newAlliance.month = _TimeSystem.month;
newAlliance2.month = _TimeSystem.month;
newAlliance.day = _TimeSystem.displayday;
newAlliance2.day = _TimeSystem.displayday;
newAlliance.favors = 0;
newAlliance2.favors = 0;
newAlliance.trust = 10;
newAlliance2.trust = 10;
print(newAlliance.nation2.Name);
nation.Allies.Add(newAlliance);
newAlly.Allies.Add(newAlliance2);
,
Answer by alterix97 · Apr 17, 2020 at 11:48 PM
Weirdly Enough changing newAlliance.nation1 = nation; newAlliance2.nation1 = newAlly; newAlliance.nation2 = newAlly; newAlliance2.nation1 = nation;
to newAlliance.nation1 = nation; newAlliance2.nation1 = newAlly; newAlliance.nation2 = newAlly; newAlliance2.nation2 = nation;
fixed the problem
Your answer
Follow this Question
Related Questions
Keep list of GameObjects between scenes 2 Answers
C# - How to get only Distinct values (with threshold) and a specific count? 0 Answers
Error when transferring items from one list to another 1 Answer
How to create a List containing all the different variables within a script (regardless of type)? 1 Answer
Multiple Cars not working 1 Answer