I have a moving ball that I want to be intercepted by a player.

I need to calculate the distance from the player to the ball direction, as indicated in the picture above. Please help.

Thanks!

I have a moving ball that I want to be intercepted by a player.

I need to calculate the distance from the player to the ball direction, as indicated in the picture above. Please help.

Thanks!

Do you know the coordinates of the intersection point? Do you have the velocity of the ball? You could use basic physics to determine how long it will take the ball to reach the 90 degree point. Use that time to determine how fast the player must go in order to reach that point at the same time.

Ok, so now that I better understand the problem:

You’d want to calculate the distance between the point and the Ray, as I just answered in your other question here.

In this case, the variables you’d use are as follows:

```
float distance = Vector3.Cross(ball.rigidbody.velocity.normalized, player.transform.position - ball.transform.position).magnitude;
```

Edit: Forgot to normalize the velocity.