Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Is there a way to edit MeshCollider convex lines?

Discussion in 'Physics' started by Chajnik, Jun 30, 2023.

  1. Chajnik

    Chajnik

    Joined:
    Feb 28, 2020
    Posts:
    6
    Basically the title. I have a pizza box model, that I made and I want it to be affected by the physics and interact react to objects if something, for example, hit it. Hence I have added RigidBody to the object with `Is Kinematic` unchecked.
    The problem here is that while all the collision works fine, the MessCollider convex created wrong collider outline because of that anything can collide with the box in an open space (see the screenshot). If I remove the convex, then the object will fall through scene and won't react to any collision. Only solution I can come up with is to make multiple simple BoxColliders and place them in the object, but that might not be the best solution if I will have such problem in the future with more complex object.

    Any help would be really appreciated!
    pizza_box_open.png
     
  2. tjmaul

    tjmaul

    Joined:
    Aug 29, 2018
    Posts:
    464
    Unfortunately that’s how it works. With the assumption of convexity, the computations needed for finding out if two things collide are orders of magnitude faster than without this assumption. That’s why dynamic rigidbodies only support convex colliders.
    in your case, I’d just create two separate meshes in your 3D modeling software and import it like this. Add a mesh collider to each of them an check „is convex“.
    I guess that is the easiest solution if it’s good enough for your purpose. At least better than fiddling with box colliders and matching the orientation of the mesh :)
     
  3. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    Don't use MeshCollider but instead add two BoxColliders to your pizza box and adjust them manually to match the top and the bottom. Do this for all your gameobjects and simply stay off MeshCollider. This doesn't usually take much work when you store these colliders in your prefab.