Search Unity

Question Is there a better way to make a detailed convex or non kinematic rigidbody compatible collider

Discussion in 'Windows' started by stakensj, Mar 18, 2023.

  1. stakensj

    stakensj

    Joined:
    Oct 23, 2020
    Posts:
    35
    So I have this mesh that I want to turn into a collider, however, the convex mesh is too far from what I need, so is there a better way than splitting the mesh into 10 separate objects and using them as a single collider?

    The perfect non-convex mesh collider:



    the same mesh but convex:


    The better collider made out of the mesh seperated into 10 parts, it works but its very time consuming:


    so is there any better way?
     
    Last edited: Mar 19, 2023
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,429
    I found a convex hull library online, and made a small script that lets me make better car colliders. First, I mark out regions of a model with simple colliders. Then I find all the mesh vertices inside those regions. Then I find the convex hull of those vertices, and make a closed mesh from those. Then I provide those closed convex meshes to Unity and discard the region colliders.

    There's a store asset called Timpie or something similar, which does a lot of the same work. They have a pretty friendly "paint the polygons" UI to define those regions, but beyond that it's the same concept. Decide what portions of a model are mostly convex as it is, make a convex hull mesh of just those vertices, and repeat until you have covered the whole model (or the parts you can't allow to clip through).
     
  3. stakensj

    stakensj

    Joined:
    Oct 23, 2020
    Posts:
    35
    that certainly would be a way to go, but I'm wondering if there is a way to make the process faster, since what I was doing there was also painting the polygons, only with the goal to separate them. And If I spend the same amount of time for every hull, its gonna take me multiple days