private void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.tag == "frog") { Frog frog = other.gameObject.GetComponent <Frog>(); if (state == State.falling) { frog.JumpedOn(); Jump(); } else { state = State.hurt; health = health - 1; healthAmount.text = health.ToString(); if (health <= 0) { SceneManager.LoadScene(SceneManager.GetActiveScene().name); } if (other.gameObject.transform.position.x > transform.position.x) { // inimigo a direita = dano + movimento para a esquerda rb.velocity = new Vector2(-pain, rb.velocity.y); } else { // inimigo a esquerda = dano + movimento para a direita rb.velocity = new Vector2(pain, rb.velocity.y); } } } else if (other.gameObject.tag == "gump") { Gump gump = other.gameObject.GetComponent <Gump>(); if (state == State.falling) { gump.JumpedOn(); Jump(); } else { state = State.hurt; health = health - 1; healthAmount.text = health.ToString(); if (health <= 0) { SceneManager.LoadScene(SceneManager.GetActiveScene().name); } if (other.gameObject.transform.position.x > transform.position.x) { // inimigo a direita = dano + movimento para a esquerda rb.velocity = new Vector2(-pain, rb.velocity.y); } else { // inimigo a esquerda = dano + movimento para a direita rb.velocity = new Vector2(pain, rb.velocity.y); } } } }