- Home /
Compound Collider - Best Practices
Hello There, I hope you are well today.
Looking for advice to build a better understanding of best practices when it comes to creating compound primitive colliders for meshes. I have prepared an example mesh below to build a little context.
If we look at the following mesh below, a simple game mesh representing a castle wall let's say - it would need to collide players and other game objects thrown at it. From your perspective what would be the best approach when creating compound colliders using primitives in Unity3D for the below example mesh?
Option 1: Vertical Colliders?
Should we place box colliders next to one another to cover the entire mesh?
QA 1.0 - Will the tiny gap between each slice cause other objects to have collision issues if colliders get stuck and glitch out? or is there a means of eliminating said gap?
Option 2: Overlapping Colliders?
Should colliders be set up to overlap to ensure there are no gaps within the compound collider mesh? In the example below there is one long horizontal collider with two overlapping vertical colliders overlapping
QA 2.0 - Will the overlap create issues with other interacting collider objects? Is it generally bad form to have colliders overlap?
Option 3: Stacked Colliders?
Should colliders be set up to stack on top of one another? In the example below there is one long horizontal collider with two stacked smaller vertical colliders on top
QA 3.0 - Similar to the first option, will the tiny gap between each slice cause other objects to have collision issues?
I understand that an alternative would be to utilise mesh colliders however for the purpose of learning lets keep mesh colliders out of scope for the advice seeked in this post.
Any advice and guidance on building compound colliders for the game mesh in question would be greatly appreciated.
Answer by sh_code · Jan 13, 2019 at 08:16 PM
I see that, sadly, nobody answered. It's sad, because in your case, the answer is extremely straightforward and simple:
whichever results in lower number of colliders, and if possible, avoid unnecessary overlaps (mostly for simplicity and clarity, compound colliders don't generate collision events with each other, naturally).
meaning, if I'm not mistaken in my maths intuition, option 3.
also, what tiny gaps are you talking about? just have the top row of colliders touch the bottom long collider.