Calculating flight time with starting velocity and drag

I’m currently working on auto-aim and AI functions that must “guess” where an object will be by the time a projectile could reach it. While weapon spread proved enough when dealing with fast projectiles, once I tried our code with slow moving, high drag projectiles, it was no longer accurate enough.

So, I need to understand how Unity uses the Rigidbody drag attribute in its calculations but I haven’t found anything. The projectile is launched with a set velocity, so in order to calculate the distance it can travel I need something like this:

r(t) = v0*t - ∫∫ aDrag dt²

But I can’t figure out what term accurately describes drag deceleration as used in Unity. Is it something akin to these?

aDrag = drag * abs(v)
aDrag = drag * v * v
aDrag = Mathf.Pow(v,drag)
aDrag = v * Mathf.Exp(drag)

I’d be really happy if someone already figured this out and could tell me. Thanks in advance.

Hi! I am currently facing the same problem, so I logged time and position of an object with rigidbody. Then I made a fit to the resulting curves. The equation, I figured out, is

s(t) = (1 - exp(-a * t)) * b

The main problem, I am still facing, is the determination of the factors a and b. As far as I can tell, the first equation to determinate the these factors is

a²*b = drag * velocity .

The second equation only works, with an error usually smaller than 1%, as long as the drag is smaller than 0.2 * velocity. It is

a = 100 * drag / (100 - drag) .

If the drag is larger, the way, that is calculated by the equation above, differs considerably. This correlation was figured out by guessing, based on the numbers, I had with my fits.

The math/physics behind the equation to describe the covered distance: the determinant differential equation is

d²s / dt² = -a * ds / dt

meaning that, the deceleration is proportional to the momentary velocity by the factor of -a. The factor b describes the covered distance for t towards infinity.