Search Unity

A question regarding when to use Mesh Colliders

Discussion in 'Physics' started by PaperMouseGames, Aug 21, 2019.

  1. PaperMouseGames

    PaperMouseGames

    Joined:
    Jul 31, 2018
    Posts:
    434
    Hi there! Hopefully this is the right place for this question, anyway I'm working on my first game and as I make some of my first 3D models I was questioning when to use mesh colliders.

    So up until now, everything I've made has used either capsule colliders or box colliders and it all seems to be working well, but I just got done making this house:

    Capture.PNG

    Ignore my really bad Blender / Art skills haha but hopefully you can see from the picture that the house can be entered.

    The house is 1 single mesh and I was wondering if something like this would be a good thing to use a mesh collider for. I only hesitate because I heard they can cause issues with performance, and if I want to have many houses I would begin to worry about them all having mesh colliders.

    Otherwise I would need at least 5 or 6 box colliders per house and I'm honestly not even sure how I would do the roof since it's rotated.

    So yeah, just wondering what the strategy is for stationary objects like this when it comes to colliders. Thanks in advance!
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    I think that a single mesh collider for that geometry would do perfectly. I don't think performance would be an issue in this case. Once instanced in the scene, each mesh collider will have its own internal bounding box so the physics would cull those that are far from the player without penalty. Just ensure don't bake all the houses together in a single mesh, but ensure each one uses its own independent mesh collider.
     
    PaperMouseGames likes this.
  3. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,073
    If it's going to be a static collider than sure you can use one big mesh collider.
     
    PaperMouseGames likes this.