using UnityEngine;
public class SwitchMethodOne : MonoBehaviour {
public GameObject currentWeapon;
public GameObject[] myWeapons = new GameObject[]
public int currentWeaponIndex = 0;
public void Awake() {
myWeapons = new GameObject[Enum.GetValue(typeof(myWeapons)).Length];
}
void Update() {
if(Input.GetButtonDown("KeyCode.LeftShift")) {
currentWeaponIndex = (currentWeaponIndex + 1) % myWeapons.Length;
currentWeapon = weaponArray[currentWeaponIndex];
Questions:
What is the purpose of “(currentWeaponIndex + 1) % myWeapons.Length;?”
. Currently, "currentWeaponsIndex" is equal to 0, so why are we just adding 1 to it?
(In reference to first question) why are we getting the remainder of 1/myWeapons.Length?
. “% myWeapons.Length;”