Search Unity

Question Question About Rigidbody Drag

Discussion in 'Physics' started by behemoth66, Nov 27, 2023.

  1. behemoth66

    behemoth66

    Joined:
    Sep 30, 2021
    Posts:
    5
    I've been learning about manual physics calculations, specifically acceleration. And now that I know a bit more about how drag is calculated, I don't think I understand what the engine is doing with this variable.

    To me it looks like the two things it could represent are air density and surface area. Maybe it represents both, maybe it represents only one or the other? The documentation I found only talked about changing it in code.

    So, what exactly does the Rigidbody drag variable represent?
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,437
    It's simply a dimensionless value that is applied to diminish velocity.

    Something similar to:
    velocity = (velocity + acceleration * Time.deltaTime) * ( 1 - drag * Time.deltaTime);


    You can decide to use it to represent aero/fluid drag, mechanical friction, magnetic reluctance, or whatever you want.
     
  3. behemoth66

    behemoth66

    Joined:
    Sep 30, 2021
    Posts:
    5
    Okay, thank you.

    So, say I throw a ball into a sand pit with a collider to tell the ball that it's in a sand pit.
    I would use whatever I think is an appropriate amount of air resistance until it hits the collider, where it would then trigger an event to turn the drag to sand pit drag?
     
  4. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,437
    That's a very common solution to the air vs water drag problem, yes.
     
  5. zulo3d

    zulo3d

    Joined:
    Feb 18, 2023
    Posts:
    1,000
    The drag setting is generally intended to be used for air friction and the physics materials are used for surface friction. But you're obviously free to remove surface friction and use the drag for both. For example when moving a rigidbody over a surface it can sometimes bounce slightly which results in very inconsistent speed and so what I'll sometimes do is disable surface friction and increase drag when on the ground and decrease it while flying through the air.