public void Disable() { Debug.Log(" trying to disable " + cat.Name); if (!enabled) { Debug.Log("already disabled " + cat.Name); return; } // StartCoroutine(changeZ()); if (IAttack != null) { Debug.Log("STOP ATTACK " + cat.Name); StopCoroutine(IAttack); } if (cAttack != null) { cAttack.setOnHit(false); } if (!owner.enemy) { target = null; } stopWalk(); blockedTime = 0; enabled = false; }
//object pooling public void getAttackObj(ExploreCat enemyCat, float damage) { if (attackObjs.Count == 0) { CreateAttackObject(enemyCat, damage); return; } cAttack = attackObjs.Dequeue(); cAttack.setOnHit(true); cAttack.setDamage(damage); }