I am able to calculate the projectile max distance, but it only works when there is no drag applied on the spherical projectile. I used the formula for range of a projectile as follows:-

void OnCollisionExit(Collision other)
    if(other.gameObject.name == "bat")
        initVel = ballRigidbody.velocity.magnitude;
        angle = Mathf.Abs(lineObject.transform.eulerAngles.x - 360);
        radianAngle = Mathf.Abs(Mathf.Deg2Rad * angle);
        maxDistance = (initVel * initVel * Mathf.Sin (2 * radianAngle))/ g;

This works well if there is no drag. But as I add drag, the range ends up being far away from where the projectile actually lands.

I looked up https://en.wikipedia.org/wiki/Projectile_motion#Trajectory_of_a_projectile_with_air_resistance

but can't quite understand how to use it.

Here's a solution I tried

if(ballHeight > maxHeight)
    maxHeight = ballHeight;
        maxHalfDistance = Vector3.Distance(ballFollow.transform.position, centerPoint.position);
        maxDistance = maxHalfDistance * Mathf.Clamp(maxHalfDistance, 1f, 1.75f);
        flag = true;

Basically calculating horizontal distance at max height and multiplying it a value between 1 and 1.75. ballFollow is horizontal position of ball and centerPoint is the launch position. This works perfectly but there is a problem that actual range isn't calculated until the ball reaches its maxHeight.

So, how can range of a projectile be calculated taking air resistance in account?

  • \$\begingroup\$ Do you have any solution so far. i need help with that also. can you give me complete script? \$\endgroup\$ – K97 Jul 9 '18 at 11:32
  • \$\begingroup\$ This webpage explains the formulas clearer than Wikipedia: grc.nasa.gov/www/k-12/airplane/flteqs.html \$\endgroup\$ – S. Tarık Çetin Jul 9 '18 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.