So I have some weird error that I cant get manage to resolve:
I am making a type of racing game, there is a class RaceManager that contains all unique Checkpoints and a class RaceAgent which is on a car and also contains the checkpoints of the RaceManager, called unpassedCPs. Each time the car passes on its targetCheckpoint, it will remove it from unpassedCPs.
However if I want to add the first checkpoint to unpassedCPs, so that the cars have to return to the start/finish to complete a round, each car will also add it to the RaceManager's checkpoints.
RaceAgent.cs:
void Setup(){ //gets called at beginning and on new round; not when finished
unpassedCPs = RaceManager.rm.checkpoints; //copy all cps
if(laps > 0){ //true when roundcourse, else it will finish at last checkpoint
//if i comment out next line, RaceManager will not add its first checkpoint, but here we are adding to RaceAgents' unpassedCPs
unpassedCPs.Add(RaceManager.rm.checkpoints[0]); //for returning back to start/finish
}
SetTargetCP(RaceManager.rm.checkpoints[0]);
}