Exemple #1
0
 void Update()
 {
     //Check the Y Axis/ vertical ones
     if (Vertical(ball.transform))
     {
         ball.ChangeY();
     }
     //Check the X axis / horizontal ones
     if (Horizontal(ball.transform))
     {
         if (ball.transform.position.x < 0)
         {
             GameManager.instance.AddPointsToP2();
         }
         else
         {
             GameManager.instance.AddPointsToP1();
         }
         ball.Reset();
         ball.SetSpeed();
     }
     //Check between paddles and ball
     if (AABBCollision(p1.transform, ball.transform) || AABBCollision(p2.transform, ball.transform))
     {
         ball.ChangeX();
     }
 }