Iteration of every variable in the foreach is not assigned to the weapon iterated.
public class CharacterAttack : MonoBehaviour { #region Fields private Weapon weapon; public List<WeaponData> weapons; #endregion private void Awake() { weapon = FindObjectOfType<Weapon>(); StartCoroutine(Shoot()); } private IEnumerator Shoot() { while (true) { foreach (var data in weapons) { var waitingShoot = data.cooldown; yield return new WaitForSeconds(waitingShoot); weapon.Shoot(); } } } } I'm doing a clone of Vampire Survivor where the character has a series of weapons that can shoot with their own variable (cooldown,range ecc.). As you can see from the code I have a list of weapons, and every weapon has its cool-down. Unfortunately, with the code I wrote, every weapon is shooting with the same cool-down timing. What I want is for each weapon to shoot with its own cool-down instead.
The script Shoot has only the instatiate().