// Update is called once per frame void Update() { if (Health <= 0.0f) { Game.InstantiateRubble(transform.position); Game.InstantiateHealthPickup(transform.position); Sounds.PlayDestroySFX(); Destroy(gameObject); } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Player") { Debug.Log("Bang"); var force = collision.impulse.magnitude; player.takeDamage(force); Sounds.PlayEnemySFX(); if (force > MinImpulse) { Game.InstantiateRubble(transform.position); Game.InstantiateHealthPickup(transform.position); Sounds.PlayDestroySFX(); Destroy(gameObject); } } }