I’m trying to put a check in my game where it disables everything that doesn’t have the same ID as the index. This is the system I have set up:
void WeaponSelect() {
selector = Input.GetAxis ("Scroll");
index += selector;
if (index > weapons) {
index = 1;
}if (index < 1) {
index = weapons;
}
check += 1;
checkedObject = weaponList[check];
if (checkedObject.GetComponent<WeaponID> ().ID == index) {
checkedObject.GetComponent<WeaponID> ().onabled = true;
} else {
checkedObject.GetComponent<WeaponID> ().onabled = false;
}
if (check > weapons) {
check = 1;
}
}
but this gives off this error:
error CS1502: The best overloaded method match for `System.Collections.Generic.List<UnityEngine.GameObject>.this[int]' has some invalid arguments
and
error CS1503: Argument `#1' cannot convert `float' expression to type `int'
If this isn’t the right way to do this, what is? Can anybody please help?