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

Unity collision meshes

Discussion in 'Editor & General Support' started by Deathrey, Nov 1, 2014.

  1. Deathrey

    Deathrey

    Joined:
    Feb 4, 2014
    Posts:
    3
    Greetings gentlemen,
    I've ran into a question regarding colliders in Unity.
    I'm buidling a static house asset. As far as I know, the best way to sort out collisions is to make a compound collider from primitives in Unity.
    However, I need quite detailed collision model plus I feel more comfortable doing collision meshes in my 3d package.

    So my question is how great is performance difference between those:
    1) 88 box colliders
    2) 88 convex mesh colliders, 8 verts each
    3) One concave mesh collider with 704 verts



    Many thanks for your replies in advance!
     
  2. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    I thought collision meshes need to have fewer than 255 triangles, and to be convex. I'd reject all three of your proposals as being too complex. Why do you "need quite detailed collision model"? I guess you think some customers might want a detailed collision mesh?
     
  3. Deathrey

    Deathrey

    Joined:
    Feb 4, 2014
    Posts:
    3
    Thank You for your reply. I need collision model, that is sufficient enough for FPS game with player being able to walk inside that building, besides there will be arrows and other projectiles which would look weird hitting empty spaces or getting stuck in areas, that are open in visible model. My estimation is that I would need roughly 80 box colliders for particular model.

    I am speaking about using 80 convex hulls with 12 triangles each.
     
  4. Valette

    Valette

    Joined:
    Jun 9, 2014
    Posts:
    68
    Are you sure you really need 80 colliders? That seems like a lot. Why don't you just use 1 box collider for the floor and a box collider on every wall? Looking at the model, assuming one or two walls inside, that would be perhaps ten colliders. Do you need to check for collisions on the roof? Also do windows need to be open? I also wouldn't give your model too must jutting geometry. I'd suggest you find a balance between the aesthetic look of the model and what makes for easy coding.
     
  5. Deathrey

    Deathrey

    Joined:
    Feb 4, 2014
    Posts:
    3
    Not sure if that would be 80, might be less, but somewhere around that number. Will there be any issues if box colliders overlap each other partially?



    Yeah player will be able to walk on the roof and each window will have 4 breakable glass panes.
    For sufficient player collisions, I would certainly use less colliders. In fact that would be 7 colliders for walls, 1 for door,1 for foundation, 2 for chimney, 5 for roof(16 in total), but what about projectiles?
     
  6. Valette

    Valette

    Joined:
    Jun 9, 2014
    Posts:
    68
    Yes, AFAIK, they can overlap without a problem and I know that PhysX engine has a limit of 65536 colliders so I guess 80 is still very low. Not used them in a FPS, myself, and my work has been based in mobile so if you're coding for PC, then you'll have plenty of room to work.

    Projectiles? You could have colliders on those too, though it depends. If you're relying on the physics engine to calculate hits based on really fast moving objects, you might run into problems. It's probably easier to now have colliders on them and do raycasts, which are discussed *everywhere* on these forums where FPS coders gather. :)
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    Just use a concave mesh collider; this is exactly what they're for (static level geometry). If the model is very complex you can produce a simplified version and use that as the collider. (A typical example is replacing steps with a ramp.)

    --Eric