I was going through a tutorial and I understood most of it. I want to ask 1 thing. This is the tutorial I am following:
https://noobtuts.com/unity/2d-pong-game
This is the Method which is called function HitFactor.
if (col.gameObject.name == "RacketLeft") {
// Calculate hit Factor
float y = hitFactor(transform.position, col.transform.position, col.collider.bounds.size.y);
// Calculate direction, make length=1 via .normalized
Vector2 dir = new Vector2(1, y).normalized;
// Set Velocity with dir * speed
GetComponent<Rigidbody2D>().velocity = dir * speed;
}
And the Hit Factor moethod is
float hitFactor(Vector2 ballPos, Vector2 racketPos,
float racketHeight) {
// ascii art:
// || 1 <- at the top of the racket
// ||
// || 0 <- at the middle of the racket
// ||
// || -1 <- at the bottom of the racket
return (ballPos.y - racketPos.y) / racketHeight;
}
Can anyone explain this to me with an example?
(ballPos.y - racketPos.y) / racketHeight;

I am really unable to understand and don't know what should I read to make myself understand this.
