Search Unity

Falling dominoes vibrating instead of settling on ground

Discussion in 'Editor & General Support' started by Gamieon, May 4, 2013.

  1. Gamieon

    Gamieon

    Joined:
    Mar 20, 2010
    Posts:
    38
    I created a video at http://www.youtube.com/watch?v=Apxb7xtmm7E&feature=youtu.be which demonstrates the issue. I knocked down a domino, the rest fell in order; but they would vibrate before settling.

    - Dynamic Friction: 0.2
    - Static Friction: 0.4
    - Bounciness: 0

    - Mass: 0.08
    - Drag: 0
    - Angular Drag: 0.05
    - g = -981
    - Size: 2.5 x 1 x 5


    Code to make it fall:
    Code (csharp):
    1. Vector3 force = -thisTransform.forward * 30.0f;
    2. thisRigidBody.AddForceAtPosition(force, thisTransform.position + new Vector3(0,5.0f,0));
    I tried the following code to make the dominoes sleep after they go below a certain threshold:

    Code (csharp):
    1. void FixedUpdate()
    2. {
    3.     if (IsSectionPlaying  !thisRigidBody.IsSleeping()
    4.          thisRigidBody.velocity.sqrMagnitude < sqrSleepVel
    5.          thisRigidBody.angularVelocity.sqrMagnitude < sqrSleepAngularVel)
    6.     {
    7.         thisRigidBody.Sleep();
    8.     }
    9. }
    But often times that made them freeze mid-fall.

    I was thinking of only making it sleep if it was facing the ground by adding a dot product threshold, but I feel like I'm overcomplicating things. I also tried adding more drag, but that didn't help.

    Does anyone have suggestions on how I should approach this?
     
  2. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Is this script on the first domino? All of them? I would think they only need gravity plus one object to knock over the first domino.
     
  3. Gamieon

    Gamieon

    Joined:
    Mar 20, 2010
    Posts:
    38
    The code to make a domino fall is only executed on the first one when you click on it....but yes they're all the same script.
     
  4. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    So, why does you code look so complicated? I mean, why not just have some collider, translate() into the first domino. The domino would have no script. Just physics. Once the collider, that pushes the first one, like a finger or soemthing, turn it off. Should the rest not just fall?
     
  5. Gamieon

    Gamieon

    Joined:
    Mar 20, 2010
    Posts:
    38
    I was able to resolve the issue by changing some settings in the PhysicsManager:

    - The bounce threshold was changed from 2 to 800
    - The min penetration for penalty was changed from 0.01 to 0.1
     
  6. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Awesome.