Hi in my game I have an array of all guns included in the game. I also have an array of the available guns in the game. Currently I am looping through all the guns in the game and if they are unlocked I will add them to the available guns array. For some reason though I cannot figure out how to add a game object to an array.
public Gun[] guns;
public Gun[] availableGuns;
void Start(){
for (int i = 0; i < guns.Length; i++) {
if ((GameDataManager.publicInstance.gunAvailability & 1 << i) == 1 << i) {
availableGuns [i] = guns [i];
}
}
}
so essentially I am having problems with this line of code:
availableGuns [i] = guns [i];
Because It does not work as well as me not wanting the available gun to be in the same position it was in the guns
array I just want it to be added onto the available guns array.
Note:
I did edit the guns[]
in the inspector whereas I did not change the availableGuns[]
at all in the inspector.