Search Unity

How to Calculate Drag Force?

Discussion in 'Physics' started by tegstewart, Feb 12, 2019.

  1. tegstewart

    tegstewart

    Joined:
    Feb 8, 2019
    Posts:
    6
    The rigidbody.drag item is the drag coefficient, not the actual drag force. How do I calculate drag force in order to determine the amount of force necessary to keep an object in motion?

    I'm only looking at linear drag. I don't even want to poke the hornet's nest that is angular drag.
     
  2. BoogieD

    BoogieD

    Joined:
    Jun 8, 2016
    Posts:
    236
    Try searching for how the Rigidbody drag is calculated in Unity. I recall a fairly in depth discussion on it.
     
    SparrowGS likes this.
  3. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    Look up nvidia physics calucaltion for the coefficient, reverse engineer it from there.
     
  4. tegstewart

    tegstewart

    Joined:
    Feb 8, 2019
    Posts:
    6
    I'm finding people trying to figure it out experimentally, and their results don't match the behaviour I'm seeing. Oddly, drag appears to be based on mass; going from a 10 ton sphere with a 1 MN force on it and a 1.0 drag coefficient gets me a max speed of 92 m/s, but bumping the mass up to 20 tons reduces top speed to 43 m/s. Changing dimensions doesn't have have any effect.

    All the other posts I'm seeing are people giving up on figuring out how Unity does it and calculating it themselves.
     
  5. tegstewart

    tegstewart

    Joined:
    Feb 8, 2019
    Posts:
    6
    It doesn't calculate the drag coefficient. You enter it as a rigidbody property.
     
  6. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
  7. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    I know I meant lookup what they are doing with it in theyr docs, how do they calculate the force applied from the drag coef and velocity.
     
  8. tegstewart

    tegstewart

    Joined:
    Feb 8, 2019
    Posts:
    6
    Neither the SDK or API say anything about drag other than describing the accessor methods.
     
  9. tegstewart

    tegstewart

    Joined:
    Feb 8, 2019
    Posts:
    6
    From one of those posts: Vmax = (F/drag - (deltaT * F) / mass
    Which gives us: F = (Vmax * mass) / (1/drag - deltaT)

    But that doesn't work. The resulting force isn't enough to reach Vmax.

    From another post, it sounds like this is because forces are applied to objects before their drag is calculated, so it's improperly using post force velocity to calculate drag.

    I'm having a heck of a time figuring out how to compensate for that.
     
  10. tegstewart

    tegstewart

    Joined:
    Feb 8, 2019
    Posts:
    6
    I figured it out. Friction is also slowing down the sphere, and both the sphere and the plane it's on have to have frictionless materials applied to them. The formula works just fine at that point.
     
    Antypodish likes this.
  11. FariAnderson

    FariAnderson

    Joined:
    Jan 20, 2020
    Posts:
    37
    According to NASA, Drag is related with Velocity^2, so the Drag number in Unity can be an approximation of the rest of this formula because according to this, in reality this number is not even constant because the Area towards the Velocity can change, and unity doesn't care about the shape of the object :)
    https://www.grc.nasa.gov/www/k-12/rocket/drageq.html
     
  12. AB498

    AB498

    Joined:
    May 4, 2019
    Posts:
    17
    this worked for me
    Code (CSharp):
    1. velocity -= velocity * drag / 50
    with mass 1 and zero frictions
     
    Last edited: Jul 7, 2022