Пример #1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.name == "LeftPaddle" ||
         collision.gameObject.name == "RightPaddle")
     {
         hitSound.Play();
         direction.x = -direction.x;
     }
     else if (collision.gameObject.tag == "Boundary")
     {
         hitSound.Play();
         direction.y = -direction.y;
     }
     else if (collision.gameObject.tag == "KillBox")
     {
         transform.position = collision.transform.position; // move ball out the way
         direction          = Vector2.zero;
         pointSound.Play();
         if (collision.gameObject.name == "LeftKillBox")
         {
             scoreManager.AddRightScore();
         }
         else
         {
             scoreManager.AddLeftScore();
         }
         StartCoroutine(SpawnBall());
     }
 }