private IEnumerator ReloadingCR() { ammoParticules.Play(); reloading = true; float duration = reloadTime; float currentTime = 0f; while (reloading && currentTime < duration) { currentTime += Time.deltaTime; yield return(null); } if (reloading) { UnitHealth health = GetComponentInChildren <UnitHealth>(); health.Heal(.5f); ammo = maxAmmo; } reloading = false; if (target != null) { if (DistanceToTarget() < fightRange) { currentState.ToFightState(); } else { currentState.ToAggroState(); } } else { currentState.ToBattleState(); } ammoParticules.Stop(); }