Hi I’v used Edy car rig from the Asset store (mint) and the AIdriver tool kit for some AI cars to race,
all is good I’m just trying to implement a tracking system to show what order the cars are in (4 AI 1 player) places 1-5.
I have set up an array (or two)
private var numbers = [1,2,5,8,15]; // to store times
private var names = [“Bluecar”,“Graycar”,“Greencar”, “Yellowcar”, “Player”]; // to store which car
So I have created a set of triggers around the track, each one checks what car hits it an stores the time,
if (TriggerhitObject.gameObject == (AIcar1green)) {
numbers[3] = Time.timeSinceLevelLoad;
names[3] = “GreenCar”;
}
I then use to sort the array
System.Array.Sort(numbers, names);
The problem I am having is adding data to the array after the first time,
Can I over write just one part of the array (AIcar1 time for example) it seem to be overwriting all the entries in the array
must stress not a coder and first time playing with array (is this possible)
I thought numbers[3] = Time.timeSinceLevelLoad; would over write the 4th item in the array (the array starting at 0).
but I then just get all entries written,
I’m displaying the data (positions) like this
POS1TXT.text = (names[0] + " " + numbers[0]);
POS2TXT.text = (names[1] + " " + numbers[1]);
POS3TXT.text = (names[2] + " " + numbers[2]);
POS4TXT.text = (names[3] + " " + numbers[3]);
POS5TXT.text = (names[4] + " " + numbers[4]);
any pointer or am I going about this the wrong way?