I tried observing whether any changes to the chase radius or switching weapons (thereby switching weapon attack ranges) affected it, but without avail.
@Vladimir_Mabhena The enemy finds the player by object reference. Both have a DamageSystem (HealthSystem but I played along with Ben’s oopsie). I’ll test if the enemy ever calls the correct function first.
I found out that the weapon’s range was never being assigned. The enemy attack animation is playing and the state is assigned but no damage occurs to the player.
While debugging, only the player’s attacks were triggering breakpoints in the code.
private IEnumerator DamageAfterDelay()
{
yield return new WaitForSecondsRealtime(.5f);
DealDamage();
//^^^^^^^^^^^^^ never called after yield directive.
}
I removed this coroutine call and it began working again.
Later on, I figured out that StopAllCoroutines is pretty evil, since it causes problems for any coroutine that may ever be played. I went for an approach where I stored the UnityEngine.Coroutine handle of each coroutine to be kept track of as fields in EnemyAI.cs, and stopped these coroutines one at a time using the override for StopCoroutine which uses a Coroutine as an argument.
The drawback to this is that one must remember whichMonoBehaviourclass called a given coroutine, and stop the called coroutine through this class, otherwise Unity throws up a cryptic coroutine continue failure error, which doesn’t otherwise halt gameplay.
Removing all StopAllCoroutines calls allowed me to use coroutines normally. The idea sprang from Ben’s fix for the scene not reloading when the player was killed.