Hey all!
I am currently working on a basketball physics simulation and having a little trouble with the shifing and scaling of numbers.
Basically I want to (initially) have the player make the shot from anywhere on the court. I am doing this by measuring the distance between the transform that instantiates the ball and a transform at the center of the basket.
Then I record the exact amount of velocity on the y and z that it takes on the ball to make a perfect shot from a near and far distance.
I update the distance between the launch point and the basket on Update then when a shoot function is called I calculate the amount of force to apply to the insantiated ball as such:
driver = (distance - minDistance) / (maxDistance - minDistance);
yVelocity = driver * (maxYVelocity - minYVelocity) + minVelocity;
zVelocity = driver * (maxZVelocity - minZVelocity) + minZVelocity;
instantiatedBall.velocity = transform.TransformDirection(Vector3(0,yVelocity,zVelocity));
Shots close will usually make it (except from the sides) and very far will usually make it. But about half way through the distance range most shots fall just short of the basket (front of the rim).
Any help would be appreciated… or advice for a different approach for precision physics would be great also.
Thanks,
Matt