void applyDamage(GameObject player) { KnightScript playerScript = player.GetComponent <KnightScript>(); playerScript.takeDamage(damage); Debug.Log("player hit"); }
private void OnTriggerEnter2D(Collider2D hitInfo) { KnightScript knight = hitInfo.GetComponent <KnightScript>(); TinajaVaciaScript tinajaVacia = hitInfo.GetComponent <TinajaVaciaScript>(); TinajaLlaveScript tinajaLlave = hitInfo.GetComponent <TinajaLlaveScript>(); TinajaMonedaScript tinajaMoneda = hitInfo.GetComponent <TinajaMonedaScript>(); CoinController moneda = hitInfo.GetComponent <CoinController>(); BossScript boss = hitInfo.GetComponent <BossScript>(); Debug.Log("HIT INFO" + hitInfo.name); if (knight != null) { knight.TakeDamage(damage); Destroy(gameObject, 0f); } else if (tinajaVacia != null) { tinajaVacia.TakeDamage(damage); Destroy(gameObject, 0f); } else if (tinajaLlave != null) { tinajaLlave.TakeDamage(damage); Destroy(gameObject, 0f); } else if (tinajaMoneda != null) { tinajaMoneda.TakeDamage(damage); Destroy(gameObject, 0f); } else if (boss != null) { boss.TakeDamage(damage); Destroy(gameObject, 0f); } else { } }