title: Unity Change Ball Direction after hitting paddle in a Pong game (like in dx-ball)
body: <p>I'm struggling with how to get the ball to change the bounce based on where it hits on the paddle. Normally in a pong game, the angle changes, depending on how far from center the ball bounces, and which direction of the center it bounces.
  I managed to do something like that:</p>
  
  <pre><code>//rb = rigidbody, velOnPaddleHit = predefined float
  float dist = transform.position.x - paddle.position.x;
  dist = transform.position.x &gt; paddle.position.x ? dist : -dist;
  dist /= paddle.localScale.x/2;
  dist *= velOnPaddleHit;
  rb.addForce(dist, 0,0);
  </code></pre>
  
  <p>But it's just not working / it's weird.
  Can anyone help me?</p>
  
  <p><strong>Edit</strong>: Here's the video showing this kind of behaviour. When the ball hits the left side of the paddle, it goes left, the velocity doesn't matter</p>
  
  <p><strong><a href="https://www.youtube.com/watch?v=fHX_2DLDp1w" rel="nofollow">https://www.youtube.com/watch?v=fHX_2DLDp1w</a></strong></p>