I want to reflect my ball when it hits the paddle. If it hits the middle i want it to reflect horizontaly. The closer it get to the edges i want it to reflect sharper and sharper.
How can this be done EASILY? ive tried using angle/radians etc, but i just cant get the hang of it. Can i use any of the C#/XNA/Monogames inbuilt library to do this? Or is there some other way?
First, to reflect the ball you need the reflection vector formula.
Apply this formula with the direction of travel from the ball against the paddle's normal to get R. Examples:
Ball's direction of travel = Vector2( 0.707106781, 0.707106781 )
Paddle's normal = Vector2( -1, 0 )
R = D - 2 * dot( D, N ) * N = Vector2( -0.707106781, 0.707106781 )
Ball's direction of travel = Vector2( 1, 0 )
Paddle's normal = Vector2( -1, 0 )
R = D - 2 * dot( D, N ) * N = Vector2( -1, 0 )
Now, this may be a little uninteresting because the Paddle's normal is always (-1, 0) across the entire border (unless you hit the top and bottom). You may want to make it more interesting by interpolating the normal between two normals at the edges, like in this picture:
In black, the normals at the edges.
In orange, the interpolated normal finalNormal = lerp( A, B, W ) where A & B are the two normals, and W is a value between 0 and 1 where 0 means the ball is next to A, and 1 means the ball is next to B. Google how to write a lerp function (lerp stands for 'linear interpolation').
Make sure all your vectors are always normalized, lerp doesn't always return a normalized vector even if A & B are normalized. The reflection vector should be normalized if D and N already were, but it may not hurt to renormalize it.
You can also make it more interesting by skewing the normal slightly upwards or downwards based on the velocity at the paddle is moving, so that skilled users moving the paddle too fast will not reflect the ball 100% horizontally even when it hits the exact middle (it's a way to fake friction).