Future position vector

As the picture shows, I want to pass the ball to the future position the receiver when receiver is moving. How do I find the intersection point?

Note: Ball is passed when receiver is moving to the intersection point.

Thanks!

Ill give you a hint, use SAA (Side, angle, angle). Look at this as a triangle math problem. You know the position of the thrower and the receiver, you can easily get the distance between the two, then find their look direction (probably just gameObject.transform.position.y). Now just apply the SAA calculation.

The point may vary depending on how fast the player travels, how fast the ball will travel, etc.

What I recommend, is for you to decide in advance how long it will take for the ball to arrive at the players location, and then calculate the speed and angle of the pass.

To do that we’ll use physics equations.

Vector3 meetingPosition = receiver.transform.position + receiver.rigidbody.velocity * passTime;

So the meeting position will be the starting position of the reciever, plus the distance he will travel, which is actualy the velocity vector times how long it will take the ball to reach him (that is passTime).

Now to calculate the direction of the pass:

Vector3 ballVelocityDirection = meetingPosition - ball.transform.position;

This is the vector that points from the ball’s current location to where they will meet.

Last, to calculate the magnitude of the pass velocity:

float ballVelocityMagnitude = ballVelocityDirection.magnitude / passTime;

Since the distance = velocity * time, we get that velocity = distance / time

Last, give the ball the velocity it needs to get to the destination:

ball.rigidbody.velocity = ballVelocityDirection.normalized * ballVelocityMagnitude;

Multiply the normalized (size 1) version of the ball’s direction with the magnitude you want it to be.

Good luck.