Problem with non convex mesh colliders

I have a little problem trying to use a mesh collider. If I don’t activate the ‘Convex’ option, it doesn’t register a collision. But I need it to be precisely the shape I have created, not a convex hull. Can I somehow increase the number of substeps in the physics simulation or do anything else to make it work?

4 Answers

4

You can increase the physics solver iteration count in Edit → Project Settings → Physics. Default is 6 I believe.

You can also experiment with the “Interpolate” and “Collision Detection” properties on any rigid bodies that are colliding with your mesh collider. Try Continuous instead of Discrete collision, especially if anything is moving quickly.

Does any of that help?

The collider in question is not moving at all, it is created and destroyed 15 fixed timesteps later. It is also the only rigid body involved. Sadly none of the above changed anything. I think I'll have to create a convex version of the hitbox that still covers all of what I need withoug cutting into areas that should not collide... Thanks anyway.

How are you using it? You could try making a compound collider out of several primitives. Also, I was given to believe that collision messages only got sent by rigidbodies- how is it the only rigidbody in your scene if it isn't moving? If the other objects do not use rigidbody physics, they should not be colliding with anything, let alone a mesh collider.

I'm not OP but this helped me thx

It is a common problem when two mesh colliders hit. One of them needs to be convex so if it is your weapon then sometimes you will register very imprecise collisions because of the convex limitation.
The usual workaround is to build a compound collider with multiple primitives (usually boxes or spheres) to approximate the object in question. In many cases it is simple because with 2 or 3 it will work, but many other times you need a more complex setup and doing this manually is a lot of work.

We’ve developed a solution to do this automatically. One example we show is precisely an Axe, but in that case what I’d recommend is to use two or three box colliders since you don’t need such an extreme precision for that.

Anyway, here’s a video showcasing the component: 1

It is available at the Asset Store: 2

Use the NonConvexMeshCollider script to solve your problem:

http://www.productivity-boost.com/DownloadNonConvexMeshCollider.html

I implemented that by myself because I had the same problem.

Turn on ‘Queries Hit Backfaces’ in the PhysicsManager (Edit → Project Settings → Physics). At least that helped me :slight_smile: