Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

A question regarding when to use Mesh Colliders

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

  1. Nerevar7

    Nerevar7

    Joined:
    Jul 31, 2018
    Posts:
    85
    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:
    1,541
    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.
     
    Nerevar7 likes this.
  3. koirat

    koirat

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