Example #1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        laser beam = col.gameObject.GetComponent <laser>();

        if (beam)
        {
            health -= beam.GetDamage();
            healthdisplay.HealthDamaged((int)beam.GetDamage());
            if (health <= 0)
            {
                AudioSource.PlayClipAtPoint(playerDestroyed, transform.position);
                Destroy(this.gameObject);
                level_manager.LoadLevel("Lose");
            }
            beam.Hit();
        }
    }