//When the player touches an enemy the Danger and Invulnerability functions are called private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.GetComponent <Enemy>() != null) { Enemy eb = collision.gameObject.GetComponent <Enemy>(); //If the enemies size is more than the playes, the player takes damage //If the enemies size is less than the players, the enemy is destroyed and the players size increases if (eb.size > size) { Damage(1); Invulnerability(2); } else if (eb.size <= size) { size += eb.size / 5; if (size > 50) { size = 50; } Spawning.respawn(collision.gameObject, this.gameObject); //Destroy(collision.gameObject); } } }