- Home /
How to calculate projectile (baseball) distance with drag factor
I am making a baseball game and need help calculating the landing spot of a hit ball. I know the velocity and the launch angle, so I can use this code to project the landing spot without drag:
float dist = ((velocity * velocity) * Mathf.Sin(2 * ball.lastHitData.launchangle * Mathf.Deg2Rad)) / 9.81f;
Unfortunately, having no drag is unrealistic, and as of now the ball's rigidbody has the Drag property set to .2. How can I calculate the landing distance with the RigidBody Drag factor incorporated?
Answer by Bunny83 · Oct 22, 2016 at 07:01 PM
That's quite difficult. See my answer on this forum post on how the drag value is applied.
Unity's drag is just a linear drag and doesn't represent real world drag .
But it is possible to predict the distance as soon as the ball is hit or would I have to keep checking over time? Since drag is applied every frame wouldn't I have to do that?
Your answer
Follow this Question
Related Questions
Shooting a cannonball. 6 Answers
Projectile collides, freezes, but flips to weird angle. Help! 0 Answers
Fireing a tank projectile. 1 Answer
Projectile Boomerang 1 Answer