Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

3D Physics Material Combine Friction/Bounce in 2D Physics?

Discussion in 'Physics' started by Deeeds, Apr 4, 2018.

  1. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    In the 3D physics materials, there's a way to combine the influence of friction and bounciness between colliding objects in four key ways:

    - Average :: The two friction values are averaged.
    - Minimum:: The smallest of the two values is used.
    - Maximum: The largest of the two values is used.
    - Multiply :: The friction values are multiplied with each other.

    Is there any way to do this with 2D physics materials?
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,470
    No, those modes are not available but have already been added as a feature to be implemented in 2018.3
     
    Deeeds likes this.
  3. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    THANK YOU for this succinct, forthright and precise answer. I'll roll-my-own for now, and look forward to this in the future.

    again... THANK YOU!!!

    Btw, thank you, as a whole, for what you've done (and doing) with 2D physics. You and your focus on 2D and physics are a good portion of why I've chosen to use Unity.
     
    MelvMay likes this.
  4. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    What's it on, for friction, at the moment?

    It feels like it's multiply, but capped at a maximum of 1.0
     
  5. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    And bounce seems to be on Maximum. But I'm just going off feel. I could be wrong.
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,470
    You can see it in the Box2D source here. Look for "b2MixFriction" and "b2MixRestitution" (bounce).
     
    Deeeds likes this.
  7. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739

    THANK YOU!!!

    This makes a LOT of sense:

    Code (CSharp):
    1. /// Friction mixing law. The idea is to allow either fixture to drive the friction to zero.
    2. /// For example, anything slides on ice.
    3. inline float32 b2MixFriction(float32 friction1, float32 friction2)
    4. {
    5.     return b2Sqrt(friction1 * friction2);
    6. }
    7.  
    8. /////////////
    9. #define    b2Sqrt(x)    sqrtf(x)
     
  8. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    Any news on that? I don't see it in the 2018.3b Release Notes.
     
  9. TFRhythm

    TFRhythm

    Joined:
    Nov 25, 2017
    Posts:
    2
    Not to beat a horse that's been dead for several years now, but has this idea been scrapped? Seems to still be unavailable as of 2023.2.

    Would definitely be a useful feature. I'm surprised it wasn't done this way by default given how useful it is with PhysX.

    Does Unity allow a way to directly edit the Box2D code?
     
    Last edited: Sep 5, 2023