/* Detect collisions with enemies and reduce the number of lives on damage. */
    void OnTriggerEnter2D(Collider2D col)
    {
        Debug.Log("COLLISION/n");
        if (col.gameObject.tag == "Enemy")
        {
            EnemyBehaviour enemyScript = col.gameObject.GetComponent <EnemyBehaviour>();

            if (enemyScript.CanDamage())
            {
                availableLives--;
                enemyScript.HasDamaged(); // Set enemy's ability to damage to false

                // Play the appropriate damage animation
                if (this.transform.position.x >= 0)
                {
                    anim.SetTrigger("Dmg_R");
                }
                else if (this.transform.position.x < 0)
                {
                    anim.SetTrigger("Dmg_L");
                }

                // Remove one life icon from the Canvas
                if (availableLives >= 0)
                {
                    var lifeIcon = GameObject.Find("life" + (availableLives + 1));
                    lifeIcon.SetActive(false);
                    Debug.Log("life" + (availableLives + 1) + "\n");
                }

                // GAME OVER
                if (availableLives < 0)
                {
                    persistentData.SetDistance(metersUp);
                    SceneManager.LoadScene(2);
                }
            }
        }
    }