private void OnCollisionEnter2D(Collision2D collision) { this.GetComponent <AudioSource>().Play(); float hitLocation = GetRacketHitLocation(transform.position, collision.transform.position, collision.collider.bounds.size.y); switch (collision.gameObject.name) { case "RacketLeft": Vector2 directionRight = new Vector2(1, hitLocation).normalized; GetComponent <Rigidbody2D>().velocity = directionRight * ballSpeed; break; case "RacketRight": Vector2 directionLeft = new Vector2(-1, hitLocation).normalized; GetComponent <Rigidbody2D>().velocity = directionLeft * ballSpeed; break; case "WallLeft": case "WallRight": RoundController.NewRoundStart(collision.gameObject.name); break; } }