Search Unity

Weird unexpected bounce behavior

Discussion in 'Physics' started by Dalon9, Jun 29, 2020.

  1. Dalon9

    Dalon9

    Joined:
    Oct 3, 2016
    Posts:
    2
    Hello,

    I stumbled across a really strange rigidbody-bounce behavior that can't possibly be intended like that.
    I've got the following setup:

    I have spheres with a rigidbody, no drag, angular drag or gravity and collision detection set to continuous dynamic as well as a physic material with static friction, dynamic friction and bounciness set to 0.5 (everything above 0 generates similar results) and both combines set to maximum.
    Components.PNG

    Those spheres hit a box at a 30° angle without colliding with each other. Each sphere's velocity is 0.01 higher than the previous one. The result is this:
    physics.gif

    I also used animation curves to graph the sphere's speed and its angular velocity after the impact in relation to its initial speed:

    Speed: Speed02.png

    Angular Velocity: AngularVelocity02.png

    So the behavior is very strange in general but at a certain speed, the spheres periodically don't get any angular velocity at all from the impact, which makes it even weirder.

    I also tried to lower the fixed timestep from 0.02 to 0.01 but that way the only thing that changes is that the "no angular velocity behavior" just starts at a lower initial speed.
    And I tested using continuous speculative collision detection, but that leads to a whole different, but also very strange behavior.
    I've put graphs to those tests into a zip file because I can only have 5 files in a post.


    So my question is: What the hell is happening here?
     

    Attached Files:

  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    Just curious, if you leave a little more time between spawning spheres does the behavior change? (Are they hitting each other?)
     
  3. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Maybe there is some code in Update? I haven't specifically tested this, but I think that even the instancing code should run in FixedUpdate.
     
  4. Dalon9

    Dalon9

    Joined:
    Oct 3, 2016
    Posts:
    2
    Thanks for the replies!

    They shouldn't collide with each other. I put the spheres on a layer and disabled collision with the same layer in the layer collision matrix. But I made another test with more time in between the spawns, just to be sure
    physics1.gif

    The interesting thing is that it doesn't seem to matter, whhere/when the spheres are spawned, because the same speed always results in the same behavior. But I made a new test where I spawn the spheres in FixedUpdate. Just with eight different speeds this time (looping): 3.5, 3.7, 3.9, 4.1, 4.3, 4.5, 4.7 and 4.9. This also nicely shows, how inconsistent and unintuitive the bounces are, depending on the collision speed.
    physics2.gif
     
  5. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
  6. JimmyTurbo1985

    JimmyTurbo1985

    Joined:
    Jun 6, 2020
    Posts:
    2
    I've noticed another strange issue but it could be something I'm doing wrong as I'm new to Unity.
    What do you think of this behavior ?
    Video below :
     
  7. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    That's related with the parameter "Bounce Threshold" in Project Settings > Physics. When the relative velocity of a contact is below that threshold then the object won't bounce.
     
  8. JimmyTurbo1985

    JimmyTurbo1985

    Joined:
    Jun 6, 2020
    Posts:
    2
    Thanks, glad there's a way to fix this!
     
  9. gamefish

    gamefish

    Joined:
    Jul 5, 2013
    Posts:
    14
    Did you find a solution for this? I don't know the size of those balls but maybe they are small balls. If this is the case, increase the ball size to 1 might help