void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag == "Player") { StaticManager.soundmanager.PlaySound("choque"); GameObject hit = col.gameObject; Barravida vida = hit.GetComponent <Barravida>(); if (vida != null) { vida.TakeDamage(10.0f); } Die(); } }
void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.tag == "Enemy") { col.gameObject.GetComponent <Enemigo>().Damage(); gameObject.SetActive(false); print("Golpie enemigo"); } if (col.gameObject.tag == "Finish") { gameObject.SetActive(false); print("Golpie fin de escenario"); } GameObject hit = col.gameObject; Barravida health = hit.GetComponent <Barravida>(); if (health != null) { health.TakeDamage(10f); } }