Mysterious video game drag model - any ideas?

AI Thread Summary
The discussion focuses on the drag model used in the game ArmA 2, specifically how to calculate the bullet's velocity over distance. Initial data shows a significant decrease in velocity from 900 m/s to 352 m/s over 1000 meters, with a given air friction value of -0.0009324. Participants suggest using a piecewise linear approximation to update the bullet's velocity based on changing acceleration due to drag, calculated every 10 meters for accuracy. The calculations align with in-game results, demonstrating the complexity of simulating realistic ballistics in video games. The conversation highlights the challenges of accurately modeling drag and the reliance on empirical ballistic tables in real-world applications.
Gews
Messages
7
Reaction score
0
In the game ArmA 2 they try to simulate ballistics and have some kind of drag model. I would like to try to find out how it works.

I collected the following data from a bullet fired from a rifle in the game.


Initial Velocity: 900 m/s Time of flight: 0.000 sec

100m Velocity: 819 m/s Time of flight: 0.114 sec
200m Velocity: 746 m/s Time of flight: 0.226 sec
400m Velocity: 618 m/s Time of flight: 0.543 sec
600m Velocity: 512 m/s Time of flight: 0.913 sec
1000m Velocity: 352 m/s Time of flight: 1.835 sec


The only given value given relating to the drag was "airFriction = -0.0009324".

Can be calculated as:
airFriction = accel / speed^2
using real world acceleration and speed of the bullet from ballistic tables.


This is a negative value and I'm not sure how to calculate it using that formula.


I would like to know how I can derive some kind of equation that will give the final velocity of a projectile launched at 900 m/s matching that of the projectile above, or at least more clues on how they decided to program their in-game ballistic physics.
 
Physics news on Phys.org
Ok, this does not look like a homework question (unless you have a pretty cool teacher), so I suppose one can answer it.

The actual force due to friction will depend on the velocity of your bullet. What you want is the instantaneous acceleration which will slow your bullet down.

As you already said, you have airFriction = accel / speed^2.

That means you will get accel=airFriction*speed^2. This will actually be a negative value. It should be as it slows the bullet down. Now, I suppose in a computer game they perform a piecewise linear approximation of the velocity.

So beginning with a velocity v0 at some time t0, when checking at some time t1, the new velocity v1 will be reduced as:
v1=v0-accel1*(t1-t0).

Now you can continue calculating a new acceleration due to the new speed
v2=v1-accel2*(t2-t1)
and so on.

Obviously the acceleration will instantly change as the velocity changes, but this is a video game. I do not think they can sacrifice that much processor cycles to get things perfect, so piecewise approximation should be fine.

Using this simple model and plugging in the numbers you gave, I also roughly get the velocities you presented.
 
Thank you for you help. I spent a while on this and it was frustrating to begin with until the answer finally clicked. Apparently this has puzzled more than a few people since this game series has a large "modding" community who like to understand how things work, for example to make a script to direct artillery shells or a sniper's bullet.

The part you mentioned about the acceleration always changing was bothering me, since that would require a massive amount of calculations, not a simple formula, but that turned out to be the missing piece of the puzzle.

I solved it by calculating a new acceleration value each 10 meters until 100 m- the answer I got corresponded to the 819 m/s velocity, so I made an Excel spreadsheet with these formulas and all the values match up exactly, at every range.

I tested the in-game speed of the bullet at 1400 meters (an extremely long distance for this game), and it matched the value on my spreadsheet exactly.
Interestingly, if I change the spreadsheet to calculate a new acceleration every 5 meters (instead of every 10) the values the come up are slightly wrong. It appears they do it every 10 meters like I originally tested out, or at least somewhere close to that.

This the game must be running these formulas over 50 times per second, as well as calculating the acceleration due to gravity and many other things, and that is for every shot, so if someone is firing a machine gun there are a huge amount of calculations going on.

I'm impressed...
 
Gews said:
Interestingly, if I change the spreadsheet to calculate a new acceleration every 5 meters (instead of every 10) the values the come up are slightly wrong.
It's more likely that calculating every 5 meters produces a more accurate result, but one that differs from the longer step period used by the game. I'm surprised they did this based on distance instead of time. Wiki has an article about how complicated drag is. In order to use the classic formula for drag based on coefficient of drag x speed^2, they "cheat" by allowing coefficient of drag to also be a function of speed, where the function just interpolates between sample points in a table. This is mostly a problem for supersonic and transonic speeds. Link to wiki article:

wiki_external_ballistics_drag_table.htm
 
It's more likely that calculating every 5 meters produces a more accurate result, but one that differs from the longer step period used by the game. I'm surprised they did this based on distance instead of time.

You're right, decreasing the intervals made the values differ from those produced by the game. I don't know how they did it for sure, but my results seem completely accurate to the game's, which was what I was looking for.

In real life (non video game) ballistics there are several extremely long tables which were found using empirical methods... these are what most people use to calculate their information. Some of these tables were created in the 19th century. They used different shaped projectiles to create the tables, G1, G5, G7, etc. G1 is suited to "flatbase projectiles with 2 caliber (blunt) nose ogives", for example. Projectiles will have a ballistic coefficient to be used with a particular table.

The tables look like so:--V----DD-----D------ DT------ T
4400 22.2 0.0 0.00505 0.0000
4390 22.2 22.2 0.00506 0.0051
4380 22.2 44.4 0.00507 0.0101
4370 22.3 66.6 0.00511 0.0152
4360 22.4 88.9 0.00514 0.0203
Nowadays they are most commonly found in the code of ballistics programs, it's too inconvenient to calculate it by hand when you can just type in the ballistic coefficient and find the answer for yourself.

These tables can be surprisingly accurate, and the calculations can be adjusted for different air densities, etc. Almost no firearms companies measure or supply information such as drag coefficients because Doppler radar is expensive and most shooters don't need such information (they usually give you the BC, the G1 ballistic coefficient), but it's nice when they do.
 
Hello everyone, Consider the problem in which a car is told to travel at 30 km/h for L kilometers and then at 60 km/h for another L kilometers. Next, you are asked to determine the average speed. My question is: although we know that the average speed in this case is the harmonic mean of the two speeds, is it also possible to state that the average speed over this 2L-kilometer stretch can be obtained as a weighted average of the two speeds? Best regards, DaTario
The rope is tied into the person (the load of 200 pounds) and the rope goes up from the person to a fixed pulley and back down to his hands. He hauls the rope to suspend himself in the air. What is the mechanical advantage of the system? The person will indeed only have to lift half of his body weight (roughly 100 pounds) because he now lessened the load by that same amount. This APPEARS to be a 2:1 because he can hold himself with half the force, but my question is: is that mechanical...
Thread 'Beam on an inclined plane'
Hello! I have a question regarding a beam on an inclined plane. I was considering a beam resting on two supports attached to an inclined plane. I was almost sure that the lower support must be more loaded. My imagination about this problem is shown in the picture below. Here is how I wrote the condition of equilibrium forces: $$ \begin{cases} F_{g\parallel}=F_{t1}+F_{t2}, \\ F_{g\perp}=F_{r1}+F_{r2} \end{cases}. $$ On the other hand...
Back
Top