// Update is called once per frame void Update() { enr = GameObject.FindGameObjectsWithTag("Enredadera"); Trepar = Vector2.Distance(this.transform.position, Player.transform.position); foreach (GameObject Enredadera in enr) { if (Input.GetKeyDown(KeyCode.UpArrow) && Trepar <= 1.2f) { Enredadera.GetComponent <PolygonCollider2D>().enabled = true; } } }
public void OnTriggerExit2D(Collider2D coll) { enr = GameObject.FindGameObjectsWithTag("Enredadera"); if (coll.tag == "Player") { anim.SetBool("Trepar", false); anim.SetBool("Quieto", false); anim.SetBool("Costado", false); Player.GetComponent <Rigidbody2D> ().gravityScale = 1f; foreach (GameObject Enredadera in enr) { Enredadera.GetComponent <PolygonCollider2D> ().enabled = false; } } }