public override void StartAttack() { if (lastAttackTime == 0.0f || Time.time > (lastAttackTime + attackCooldown)) { // play the sound effect if (soundEffectPlayer != null) { soundEffectPlayer.PlaySpellSound(); } // remember when for cooldown purposes lastAttackTime = Time.time; // show the attack animation animator.SetBool("Attack", true); // deal damage foreach (GameObject collidingObject in collidingObjects) { Health health = collidingObject.GetComponent <Health>(); if (health != null) { health.TakeDamage(splashDamage, this); } } // create an explosion prefab GameObject explosion = Instantiate(explosionPrefab, transform); // destroy the explosion instance automatically after 1 second Destroy(explosion, 1.0f); } }