private void OnCollisionEnter2D(Collision2D other) { if (other.collider.tag == "player") { RubyController rubyController = other.gameObject.GetComponent <RubyController>(); rubyController.ChangeHp(-1); } }
private void OnTriggerStay2D(Collider2D other) { if (other.tag == "player") { RubyController rubycontroller = other.GetComponent <RubyController>(); rubycontroller.ChangeHp(-1); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "player") { RubyController rubyController = other.GetComponent <RubyController>(); if (rubyController.GetCurHp() < rubyController.m_fMaxHp) { rubyController.ChangeHp(1); rubyController.PlaySound(m_acPickUp); Instantiate(m_effectPickUp, transform.position, Quaternion.identity); Destroy(gameObject); } } }