Search Unity

How to do Box Colliders on a Triangle Shaped mesh?

Discussion in 'General Discussion' started by wuannetraam, Oct 14, 2021.

  1. wuannetraam

    wuannetraam

    Joined:
    Oct 29, 2019
    Posts:
    87
    What is the best/correct way of doing this? I have added box colliders to my object but the object has a triangle shape at the top part. I have added a box collider on it but this is not realistic as objects would bounce of an invisible part.
     

    Attached Files:

  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,569
    You place them by hand as multiple child objects.

    For this sort of object the arrangement will be like this.
    upload_2021-10-14_12-52-0.png upload_2021-10-14_12-52-21.png upload_2021-10-14_12-52-33.png
    Or, if it is a static object, you could use a mesh collider instead.
     
    Joe-Censored likes this.
  3. wuannetraam

    wuannetraam

    Joined:
    Oct 29, 2019
    Posts:
    87
    thank you. So if I use a mesh collider I don't have to put it to Convex right? becouse then the door way is also blocked by the collider.
     
  4. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    I suggest trying the multiple box colliders method that neginfinity showed in the images. It is likely to work faster.
     
    Joe-Censored likes this.
  5. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    I think I'd go with 2 box colliders for the bottom part and 1 convex mesh collider for the top triangle.
     
  6. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,569
    Primitives (box colliders) are faster than Convex Mesh Collider.
    Convex Mesh Colliders are faster than Non-Convex Mesh Colliders.
    Only Convex mesh colliders can collide with other mesh colliders.
    Convex mesh colliders are limited to 255 triangles per collider.

    So constructing collider out of boxes like I suggested will result in best performance.
    And if you expect this building piece to ever fall down using physics, you'll have to build it out of boxes.
     
    Joe-Censored likes this.