void Start() { LeftBallCount = 0; RightBallCount = 0; leftText.text = LeftBallCount.ToString(); rightText.text = RightBallCount.ToString(); }
void OnTriggerExit2D(Collider2D collision) { collision.transform.SetParent(null); if (collision.transform.CompareTag("Ball")) { --LeftBallCount; leftText.text = LeftBallCount.ToString(); } if (collision.transform.CompareTag("AIBall")) { --RightBallCount; rightText.text = RightBallCount.ToString(); } BasketBall basket = collision.GetComponent <BasketBall>(); basket.SetActiveTraill(true); }
void OnTriggerEnter2D(Collider2D collision) { if (collision.transform.CompareTag("Ball")) { ++LeftBallCount; leftText.text = LeftBallCount.ToString(); AudioManager.Instance.PlaySound(eSoundId.Score); goalInEffectPrefab.PlayEffect(collision.transform); } else if (collision.transform.CompareTag("AIBall")) { ++RightBallCount; rightText.text = RightBallCount.ToString(); AudioManager.Instance.PlaySound(eSoundId.Score); goalInEffectPrefab.PlayEffect(collision.transform); } BasketBall basket = collision.GetComponent <BasketBall>(); basket.SetActiveTraill(false); }