void OnCollisionEnter2D(Collision2D other) { Vector2 dir = Vector2.zero; switch (other.gameObject.name) { case "edge_r": ResetBall(); // Update score ScoreData.m_P1Score += 1; canvasMaster.UpdateScoreHUD(); // Ball starts moving dir = new Vector2(2, 0).normalized; physicsBody.AddForce(dir * m_Force); // SFX m_SFXSource.PlayOneShot(m_HitEdgeSFX); break; case "edge_l": ResetBall(); // Update score ScoreData.m_P2Score += 1; canvasMaster.UpdateScoreHUD(); // Ball starts moving dir = new Vector2(-2, 0).normalized; physicsBody.AddForce(dir * m_Force); // SFX m_SFXSource.PlayOneShot(m_HitEdgeSFX); break; case "player1": Bounce(other, dir); break; case "player2": Bounce(other, dir); break; default: break; } }