Search Unity

Rigidbody balls inside a rigidbody container

Discussion in 'Physics' started by kqmdjc8, Aug 19, 2019.

  1. kqmdjc8

    kqmdjc8

    Joined:
    Jan 3, 2019
    Posts:
    86
    Hello. In my game there are drawers which can be opened (opening occurs by animation of a drawer) and they contain items (rigidbodies).

    My problem is that walls of drawer are really thin so I need Continous collision detection for items inside. Drawer doesn't use gravity and its position is controlled with animation so it has isKinematic checked true. The problem is that Unity forces me to use Speculative collision detection as the rigidbody has isKinematic checked true.

    Ball has continous collision and it doesn't work as intended.
    Video explains the problem


    I can see 3 solutions:
    1. Bigger wall colliders - it basically messes things up - long to explain, trust me it can't work for me
    2. Dont check isKinematic on drawer - tried it and it brought tons of problems, i've lost control over a drawer
    3. Decrease fixed time-step - I can eventually do this and it kind of works but I just believe there is a better solution
     
  2. kqmdjc8

    kqmdjc8

    Joined:
    Jan 3, 2019
    Posts:
    86
    Anyone help? I've increased fixed time-step for now but Im getting really small items to go through walls anyway
     
  3. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    88
    Add rigidbody on your drawers make them dynamic (make walls out of boxes) and move them only by AddForce.
    CCD will only work inside physics engine. If you move your objects via transform change for physics it's like teleportation of objects.
     
  4. kqmdjc8

    kqmdjc8

    Joined:
    Jan 3, 2019
    Posts:
    86
    Thanks for help. I've solved problem in another way. Whenever something is in drawer it becomes its child