Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Summer Special
      2. The Diamond Casino Heist
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Frontier Pursuits
      2. Find Lobbies & Outlaws
      3. Help & Support
    3. Crews

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

    2. GTA 6

      1. St Andrews Cathedral
    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    3. Gangs

    1. Announcements

    2. Support

    3. Suggestions

Please be aware that this is not a tutorial request forum! Use the appropriate topic for the effect.
Sign in to follow this  

[IV] Mass, Weight, and Drag

Recommended Posts


While developing flight simulation scripts for IV:SA, I came across several odd behaviors of IV physics, at least, as experienced through ScriptHook. Recently, it became necessary to pinpoint the exact physics of weight and drag, and so I had conducted a small study. I am sharing the results of the study here, hoping that it will be helpful for people developing other mods for IV and future GTA titles.





Vehicles, like many other objects, follow Newtonian Physics. The principle equation is the Newton's Second Law, stating that ΣF = ma. That is, sum of all forces acting on the object is proportional to acceleration. It is, therefore, useful to know the exact value of m for a vehicle. Furthermore, in addition to any forces applied due to the engine, which can be disabled, and forces applied by the script, every vehicle is persistently acted on by two forces. These forces are weight and drag. Weight is constant, depending on mass and acceleration due to gravity. Drag varies based on vehicle velocity and drag multiplier. In general, drag can have rather complex dependence on velocity, but in simulations it is often represented with simple linear or quadratic dependence on velocity.


Based on Cerbera's detailed study Handling - Acceleration Experiments and believing that the drag model is going to be essentially the same, I have settled on quadratic drag. With that and above considerations, the goal of the study is to find the coefficients under which the expression guiding motion of the vehicle is given by a simple formula.


ma = F - kv² - mg [1]


Where F is the sum of all external forces applied to the vehicle by the script, k is the drag coefficient, m is mass of the vehicle, v is its velocity, a is the acceleration, and g is acceleration due to gravity.





For the testing, Shamal was used with the following handling data.



SHAMAL   8000.0 10.0 75 0.0 0.0 -0.5 0.0 1 2.00 4.0 40.0 0.4 0.60 0.7 35.0 0.65 0.60 8.0 0.10 0.5 5.0 1.3 1.3 0.05 -0.14 0.0 0.5 1.2 0.8 0.8 1.5 3.0 45000 06004000 00400000 13 



The mass is set to 8 tons, corresponding to fully loaded weight of Learjet 55, and drag multiplier is left at the default value. Engine thrust, at 32kN max total, and wing lift based on aerodynamic computations are added by the script to allow flight. Flight recorder code was added to the script, logging the time, aircraft position and velocity as reported by the script, and sum of all forces applied to the aircraft by the script. The last three are vectors with 3 components each, resulting in 10 entries per simulation tick. Time was logged in milliseconds, and the rest in units natural to the engine, being meters, meters per second, and Newtons respectively.


Collected data was analyzed in several stages. First, 2000 entries corresponding to roughly 70 seconds of flight time were used, discarding the first 30 seconds of simulation that included grounded time. Grounded time was discarded since there is no reasonable way to account for interaction forces between aircraft and runway.


Next, the acceleration data was derived from velocity data. Since acceleration is not tracked by engine internally, it had to be differentiated numerically, resulting in a fair deal of noise. The differentiation method used was 8th order central finite difference equation. Such high order was used to slightly average out effects of the noise, which, unfortunately, was only somewhat successful.


Finally, data was fitted to equation [1] by minimizing absolute χ² error to obtain effective mass and drag coefficient.



Data and Results.


First, it is important to note that time difference between script ticks is not consistent. Fortunately, it has no impact on forces, but it has to be taken into account any time a quantity is acquired by differentiation, as was done with acceleration in this study.


user posted image

Time vs number of ticks.


Position and velocity data logged during flight.


user posted image

Position. I was not trying to fly straight.


user posted image

Velocity. It is somewhat noisy, which results in difficulties deriving acceleration.


user posted image

Derived acceleration data. Lots of noise, but still usable.



The first round of fitting data produced g slightly over 10. Given the noise levels above and high average errors, it seems likely that the standard value g=9.8m/s² is being used by the game. Fixing the value at 9.8 and running the fits for m and k only, produced the following results.



{m -> 15773.7, k -> 15.8415}



With RMSE of roughly 20kN, or about 20% relative error. The RMSE is huge, which suggests that the values above aren't very precisely determined. Because the mass in handling is set to 8,000, and drag multiplier to 10.0, it seems plausible from above data that the values are actually 16,000 and 15.0 respectively, giving multipliers of 2.0 and 1.5 respectively.


There are two tests to this conjecture. First, we can extrapolate drag under assumptions that the above fit for the mass is correct. That is, determine what force is required to produce the observed acceleration once we take into account the weight of the object. The following drag distribution is produced.


user posted image

Extracted drag.


Here, it is plotted against aircraft velocity. In red, D=kv² model is plotted with k=15.


user posted image

Drag vs Velocity


It appears that assumption k=15 is well within error. The final test of the fits is to extract the weight of the aircraft by subtracting modeled drag and forces applied by simulation from the acceleration in z direction. In red is the expected weight under g=9.8m/s² and m=16,000kg.


user posted image



Again, there is a lot of noise, but assumptions are well within the error.





Based on Cerbera's earlier studies of effects of mass and drag multiplier on handling of the vehicles, and assuming that the same qualitative behavior holds for IV simulation, it is concluded that the mass of the vehicle, as relevant to the forces applied by the ScriptHook, is twice the mass stated in the handling.dat. While the drag multiplier used by the simulation appears to be 1.5 times the multiplier stated in handling.dat. It is not clear if these discrepancies are entirely due to the engine or are in part caused by artifacts of ScriptHook, but using the above multipliers for flight computations does produce correct results.





Thanks are due to aru for developing GTA IV C++ Script Hook and to Cerbera for previous work on vehicle handling.

  • Like 3

Share this post

Link to post
Share on other sites

On Importance of Filtering


In my original post, I have mentioned that using differentiation to get acceleration from velocity results in a very noisy acceleration data. That is to be expected. Taking derivative always amplifies any noise present, and velocity data I got from the engine was not very clean.


I have recently came across a very nice method to address that issue using Kalman Filter. I am not going to go through the details. I use a state vector that contains position, velocity, and acceleration, with acceleration being a hidden parameter. A small amount of noise is applied to the acceleration uncertainty updates to account for possible changes in acceleration. This results in very clean acceleration data that is still consistent with measurements.


Here is acceleration data before and after implementing the filter.



Derivative Kalman Filter
user posted image user posted image


Because the parameters extracted earlier were done so by fitting, noise played almost no role, so the actual results are still good. However, if instantaneous acceleration data was needed, filtering would make a crucial difference. As it stands, the difference is purely aesthetic.

  • Like 1

Share this post

Link to post
Share on other sites
Ferocious Banger

I salute you, sir.

  • Like 1

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.