private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.collider.name == "RacketPlayer1" || collision.collider.name == "RacketPlayer2")
     {
         BounceFromRacket(collision);
     }
     else if (collision.gameObject.name == "WallLeft")
     {
         scoreController.player2scores();
         StartCoroutine(ballMovement.StartBall(true));
     }
     else if (collision.gameObject.name == "WallRight")
     {
         scoreController.player1scores();
         StartCoroutine(ballMovement.StartBall(false));
     }
 }
示例#2
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.name == "Player 1" || collision.gameObject.name == "Player 2")
     {
         BounceFromRacket(collision);
     }
     else if (collision.gameObject.name == "WallLeft")
     {
         scoreController.GoalPlayer2();
         Debug.Log("Collision with wall left");
         StartCoroutine(ballMovement.StartBall(true)); //Move the ball to the left side but use the Coroutine to give a pause then move it
     }
     else if (collision.gameObject.name == "WallRight")
     {
         scoreController.GoalPlayer1();
         Debug.Log("Collision with wall right");
         StartCoroutine(ballMovement.StartBall(false)); //Move the ball to the left side but use the Coroutine to give a pause then move it
     }
 }
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.name == "RecketPlayer1" || collision.gameObject.name == "RecketPlayer2")
     {
         BounceFromRecket(collision);
     }
     else if (collision.gameObject.name == "WallLeft")
     {
         Debug.Log("Collision with WallLeft");
         scrollController.GoalPlayer2();
         StartCoroutine(ballMovement.StartBall(true));
     }
     else if (collision.gameObject.name == "WallRight")
     {
         Debug.Log("Collision with WallRight");
         scrollController.GoalPlayer1();
         StartCoroutine(ballMovement.StartBall(false));
     }
 }