- Home /
Rigidbody objects not colliding.
I have a scene using some barrels that have Rigidbody colliders on them. The player can then walk up and collide and move the barrels around.
My problem now is that my barrels won't collide with one another.
I am using a Mesh Collider (With a custom simplified Cyclinder mesh for collision) and Rigidbody collider on the barrels.
I have discovered that if I use a Box Collider instead of a Mesh one, the barrels collide like normal.
Any help would be greatly appreciated!
Can someone provide more details around this? I have a need for mesh on mesh collision. I have some very large objects that I need to get right up on and a box collider wont work. $$anonymous$$aybe I can use a box or capsule for the smaller object co$$anonymous$$g up on the larger one, but I suspect I'll have some situations where 2 large vehicles are getting up on each other and a crude box to box wont look right?
2 points:
what's this that mesh on mesh won't collide? I'm experiencing this but I don't understand why? Seems like a very odd limitation to me.
when I was writing my own engine I'd use a box or sphere collision for a crude check and then perform a more detailed mesh check only if the box/sphere check shows a collision. Doesn't Unity support something similar, and if so what's the best way to set it up?
thanks
Because it's a very expensive operation. As I mentioned in my answer, you can use convex mesh colliders, but those have limitations (such as, well, being convex, also a max of 256 polys).
Yes, that's what Unity does.
Thanks Eric.
Relative to question 2, does this happen automatically? In other words, I don't need to add two separate colliders, right? I suspect internally it's going to do a sphere distance check then apply whatever collider you've chosen for the detailed collision, or do you need to somehow specify how you want it to behave?
Answer by Eric5h5 · Nov 13, 2011 at 10:07 PM
Standard mesh colliders can't collide with other standard mesh colliders. Only convex mesh colliders can collide with each other. For performance reasons, compound primitive colliders should be used where possible. A capsule/box combo generally works well for barrels (capsule for rolling, box so they stand on end).
I see. I had a feeling that might have been the case. Good to know that I actually had thought of the capsule/box combo idea.
Thanks!
Answer by Legendofcs · Aug 17, 2013 at 03:27 PM
There 2 things 1. Rigid body 2. Mesh Collider
If you have 2 different bodies and both of them are not colliding for some reason then please make sure that they both have the above two properties
Both should be rigid bodies and both must have their meshes.
Example. BodyA is like a box and has Box Collider attached with it, It must be a rigid body attached with it as well BodyB is a sphere and has a Sphere Collider attached with it, It must be a rigid body as well. Both bodies must have their isKinematic checkbox UNCHECKED in order to fall with gravity checkbox checked.
Both bodies will collide if the above mentioned procedures are followed correctly
You do not want them to have mesh colliders. See my answer.
Answer by HipJiveGuy · Apr 07, 2019 at 12:44 AM
Sometimes, an object wont collide with another object because you have a public property like a sound or something like that that's not assigned.
If it's not assigned, then any code after trying to play the sound, or using the missing object in some way wont get run!
It may work by only disabling everything in the scene if my audio source is somewhere there blocking my collisionEnter()?
Answer by Riqaiun · Jan 19, 2015 at 02:46 AM
From the experience of my current project, I set the collision detection mode of rigidbody to be Continuous, then the rigidbody does not fall through the mesh collider of a complex object underneath.
Your answer
Follow this Question
Related Questions
collision between a rigidbody and a mesh collider not working 1 Answer
Unreliable collision detection between rigidbody and mesh collider 1 Answer
Workaround to Non-Convex mesh colliders with non-Kinematic RigidBodies? 1 Answer
How to remove internal triangle/faces when combining mesh 0 Answers
Why attach a kinematic rigidbody to a collider that moves a lot? 1 Answer