void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("PlayerTwo") && punching) { playerTwoControl = player.GetComponentInChildren <PlayerTwoControl>(); playerTwoControl.health -= (int)Random.Range(5.0f, 40.0f); } }
void Update() { playerTwoControl = player.GetComponentInChildren <PlayerTwoControl>(); health.text = "HP - " + playerTwoControl.health.ToString(); }