Search Unity

Problems with collisions while rotating a rigidbody with objects inside

Discussion in 'Physics' started by Baalhug, Sep 26, 2018.

  1. Baalhug

    Baalhug

    Joined:
    Aug 12, 2013
    Posts:
    32
    I have asked this on unity answers, but I got no answers, so I'll try here.

    I have a bucket with some objects (dice) inside and I need to move and rotate the bucket (programatically) to let the dice fall from it. I'm using mesh collider in the bucket and box colliders in the dice. The bucket and the dice all have rigidbody attached, and I tested all combinations of collision detection on them (now dice have continuous and bucket has continuous dynamic). The movement (translation) of the bucket works fine with dice in it (using rigidbody.MovePosition). But when I rotate the bucket (using rigidbody.MoveRotation) sometimes (quite often) dices pass through bucket's mesh and get lost.

    I've been researching a lot and the best related post I found about this problem is this: https://answers.unity.com/questions/23737/fast-collision-between-a-mesh-collider-and-a-conti.html (See specially the last comment on the answer).

    Maybe I can slow down the rotation of the bucket trying to find a speed which dice don't come out of the bucket too soon but they don't pass through the mesh either, but I really dislike that solution because I can't be sure it always works. So... Is really impossible to rotate a mesh collider (no matter the rotation speed) containing box colliders without having object trespassing behaviour?

    Thank you in advance
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Baalhug likes this.
  3. Baalhug

    Baalhug

    Joined:
    Aug 12, 2013
    Posts:
    32
    Oh, nice!!
     
  4. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Please let me know if you see your case to improve with Unity 2018.3.
     
  5. Marcos-Schultz

    Marcos-Schultz

    Joined:
    Feb 24, 2014
    Posts:
    381
    Raising fixedTimeStep also solves your problem, but it is not advised.

    If you are dealing with a small project with few objects with Rigidbody, it may be an option. But if you have many objects with physics, then forget it.