Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Collision Detection not working correctly

Discussion in 'Physics' started by mojer_unity, Oct 17, 2023.

  1. mojer_unity

    mojer_unity

    Joined:
    May 18, 2022
    Posts:
    2
    Hi everyone,

    I'm simulating a bin-picking application in unity, and I have added some triggers near my sucking tool, in order to detect the pieces in contact with them and attach them to the tool. However, in many cases I can visually see that the trigger is colliding with the mesh collider of the piece but the OnTriggerEnter/OnTriggerStay signals are not being called, when I move a little bit around for some configurations they are called.

    Here an image of the trigger and collider colliding without any detection:
    upload_2023-10-17_15-47-38.png
    upload_2023-10-17_15-47-53.png

    The yellow object inside the red circle are the box triggers that represent the magnet, and the purple body is the piece to grasp which is composed of two convex mesh colliders.

    Any idea about how to solve this problem? Are there any physics parameters I should modify?

    Best regards
     
  2. zulo3d

    zulo3d

    Joined:
    Feb 18, 2023
    Posts:
    757
    If the purple object is a rigidbody then it's possible that it has gone to sleep. You can make it stay awake with WakeUp.
     
    Last edited: Oct 18, 2023
  3. mojer_unity

    mojer_unity

    Joined:
    May 18, 2022
    Posts:
    2
    Thanks, I didn't know about rigidbody sleeping thank you very much.
    I reduced the sleep threshold in the project settings to zero, so now rigidbodies do not go to sleep. However, now all pieces have a small jittering and I have a weird behaviour since the piece is entering the trigger and exiting in the next physics update, but visually it is always in collision with the trigger.
    upload_2023-10-19_9-14-50.png


    Is there any workaround I can do, to still make a trigger detect a sleeping rigidbody? or at least maintain the sleeping behavour until the trigger collides with it?
     

    Attached Files:

  4. zulo3d

    zulo3d

    Joined:
    Feb 18, 2023
    Posts:
    757
    The only thing that will wake a rigibody is another rigidbody.

    Or could you make your active picker a rigidbody and the stationary passive object a trigger?. This would be closer to how God intended it to be.

    Or even better, make them both be rigidbodies?.