// Use this for initialization void Awake() { GameObject jugador = GameObject.Find("Hero"); Vidaheroe = jugador.GetComponent <controlheroe> (); characterFullLife = Vidaheroe.vida; }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.layer == 8) { controlheroe ctr = other.gameObject.GetComponent <controlheroe> (); if (ctr != null && soyPota && !cure) { ctr.RecibirDaño(curaEnNegativo); cure = true; } anim.SetTrigger("collected"); } else if (other.gameObject.layer == 13) { anim.SetTrigger("broken"); } }
// Update is called once per frame void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.layer == 14) { agarrado ctr = other.gameObject.GetComponent <agarrado> (); if (ctr != null) { ctr.romper(); } Destroy(gameObject); } else if (other.gameObject.layer == 8) { controlheroe ctr = other.gameObject.GetComponent <controlheroe> (); if (ctr != null) { ctr.RecibirDaño(daño); } } }