private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Harpoon") { hp.takeDamage(1); } }
public void takeDamage(int damage) { if (invincible == false) { if (hitSound != null && audioSource.isPlaying == false) { audioSource.PlayOneShot(hitSound); } gameObject.GetComponent <Renderer>().material.color = Color.red; health -= damage; time = 0.0f; scr_hpsystem parent = gameObject.GetComponentInParent <scr_hpsystem>(); if (parent != this) { parent.takeDamage(damage); } } }