private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Enemy") { CharachterState state = collision.gameObject.GetComponentInParent <CharachterState>(); state.hp -= damage; Destroy(gameObject); } }
private void OnCollisionStay(Collision collision) { if (timer > 0.0f) { return; } if (collision.gameObject.tag == "Player") { CharachterState state = collision.gameObject.GetComponentInParent <CharachterState>(); cachedAnimatorController.SetTrigger("Attack"); state.hp -= damage; timer = attackTime; } }