public virtual void Death() { if (Hitbox.tag != "DeadEnemy") //Call only once { if (PlayerPercentDamage >= expDamageThreshold) { player.GetComponent <PlayerStats>().AddEXP(exp_reward); QH.CheckGenericKillObjectives(transform.gameObject, new Vector2(transform.position.x, transform.position.y)); } if (Spawner_Transform) { Spawner_Transform.GetComponent <Spawner>().ChildDied(); } // Freeze the position and remove collision of the enemy rB.constraints = RigidbodyConstraints.FreezeAll; rB.angularVelocity = Vector3.zero; animationUpdater.PlayAnimation("death", false, true); EHealBar.Disable(); // Makes it so the dead enemy cannot be targeted like an alive one Hitbox.tag = "DeadEnemy"; agent.enabled = false; Hitbox.GetComponent <Collider>().enabled = false; transform.parent = deadEnemyParent; Destroy(gameObject, destroyAfterDeathDelay); } }