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?
Answer by gribbly
Sep 21, 2011 at 05:35 PM
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...
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.
For a collision, only one of the two objects has to be a rigid body.
The collider is made of three joined extruded hexagons and I use it to determine if a melee attack hits (it can hit the tile in front of the player and the two adjacent to that). The player swings his sword, a rigid body with that collider is created and if an enemy is sitting on one of the tiles, he registers a hit and is damaged accordingly. It works with standard colliders and with mesh colliders set to convex, but not with concave colliders.
But since the enemies also have a one-tile hexagonal collider, I don't have to encompass a tile completely to make the attack hit, so I rebuilt the collider for the sword-swing with a convex mesh.
The problem with the detailed hexagonal collider was, that it cut into tiles that should not be hit. The new, convex collider does not and up to now it works perfectly.
I'm not OP but this helped me thx
Answer by UGTools
Oct 30, 2012 at 04:57 PM
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: YouTube
It is available at the Asset Store: link
Answer by stanzy
Feb 22 at 10:06 AM
Use the NonConvexMeshCollider script to solve your problem:
I implemented that by myself because I had the same problem.
Answer by wolga2
Mar 09 at 04:02 PM
Turn on 'Queries Hit Backfaces' in the PhysicsManager (Edit --> Project Settings --> Physics). At least that helped me :)
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
8 People are following this question.
A node in a childnode?
Paint on object in editor and return as texture.
Autoscale Shader with multiple random texture selection.
Going through buildings?
Imported Cinema 4D Problem