Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Rigidbody's Drag impact on Gravity

Discussion in 'Physics' started by Pixsaoul, May 8, 2019.

  1. Pixsaoul

    Pixsaoul

    Joined:
    Feb 10, 2014
    Posts:
    14
    Hello,
    my question is : is there a way to remove the impact of drag (of a Rigidbody) on gravity?

    I am working on a ball controlled by forces and I wish to have it respond smoothly to user input, and therefore stop quickly. Setting the drag to 20 did the trick but the side effect is that my ball is now falling 20 times slower, that's why I would like the drag value to have no impact on the gravity force added to my ball.

    I tried to multiply the global gravity settings and it works but it really is not a scallable solution.

    I also tried to use friction coefficient but even the highest values don't grant acceptable results (to much time before stopping completely).

    If this is not possible, is there a set of multiplier I could apply to the force on my player and the rigidbody mass to have the same result ? (I don't know the formula linking forces, mass, drag and friction).

    Thank you for your time !
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,363
    Instead of adjusting the drag to a new constant that affects all velocity buildup, have you tried adjusting the velocity to 0 whenever the user provides input?
     
  3. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    Implement your own drag that only works on the X and Z axis, leaving the Y axis free for gravity
     
  4. IllTemperedTuna

    IllTemperedTuna

    Joined:
    Mar 20, 2019
    Posts:
    6
    I've had a similar issue with my project.
    One thing you can do to offset the drag discrepancy is to add a downward force that is multiplied by the drag value itself.
     
  5. Pixsaoul

    Pixsaoul

    Joined:
    Feb 10, 2014
    Posts:
    14
    Thank you for your answers, I am not a fan of setting the velocity as it seems more natural to juste mess with forces and their impact on the physics world but I keep that solution as a fallback ;)

    From your answer I think my "battle plan" will be to
    - First implement the quickest solution : add a downward force to help gravity return to a normal value
    - Then implement my own horizontal drag only so I can keep all the unity physics parameter to normal values, to ensure I keep the cohesion of various object in my project.

    Would you have by any change, an example of horizontal drag implementation ? I found the formula but I'm guessing there already is some implementation with a lot of optimization that exists.

    once again thanks !