Hello there, I am just wondering why do we calculate the offset if we are not using it to universally find the ball anywhere, so we can stick it to the ball from any start position it would have?
I mean, if I apply your code and put my ball away from paddle and start the game, the ball will keep the same X and Y coordinates from the paddle, it will not stick to it . IT will only stay sticked to it if we put the ball on the paddle before the game start.
So, to get ball on the paddle, why I cannot simply use this:
void Update () {
transform.position = new Vector2(paddlePos.x, paddlePos.y+offset);
}
While offset is sum of height of the (ball + paddle) divided by two.