Concave Collider Help

To use the concave collider first drag the ConcaveCollider script to a GameObject. Alternatively you can also add the component to the currently selected GameObject through the menu "Component"->"Ultimate Game Tools"->"Colliders"->"Concave Collider".

To compute and assign the colliders simply press the "Compute hulls" button on the component panel. Each generated hull will be added as a child of the GameObject and specified as a convex collider.

Concave_collider_properties

Properties

Algorithm

The generation method used. There are 3 algorithms available, each gives different results depending on the object:

  • Normal: The normal algorithm. Takes some time to compute.
  • Fast: The new default algorithm. Way faster and sometimes more accurate than the normal one.
  • Legacy: Old algorithm. Use only if the previous two don't work well.

Max Hull Vertices

We found out that the convex decomposition algorithm is quite sensible to the scale of the mesh. This parameter forces the convex decomposition computation to be done using the mesh rescaled to fit a sphere with radius = Internal Scale. Playing with this value can improve the final results. If you still want to use the original mesh with no processing, set it to zero.

Max Hulls

Limits the number of colliders generated.

Internal scale

We found out that the convex decomposition algorithm is quite sensible to the scale of the mesh. This parameter forces the convex decomposition computation to be done using the mesh rescaled to fit a sphere with radius = Internal Scale. Playing with this value can improve the final results. If you still want to use the original mesh with no processing, set it to zero.

Precision

Controls how precise the generation algorithm needs to be regarding concavity.

Legacy Steps

Only when "Use Legacy Method" is checked. The more steps the more precise the final result. On the other hand, more time will be needed to compute the hulls.

Enable Prefab Usage

This allows to create prefabs of objects that use the concave collider and instance them either at runtime through scripts or manually using the editor. If the colliders were generated with this option disabled, their mesh references will be empty when trying to instance a prefab.

Add Hull Meshfilter

Adds a MeshFilter containing the collision mesh to the hulls. This does not mean the object is rendered (a MeshRenderer would be necessary) but the mesh data is there and it may be used through scripting for whatever reason. By default it is disabled to save up memory.

Output Debug Messages

Outputs additional information to the console window after the hull computation.

ADVANCED OPTIONS use only if necessary and you know what you are doing!

Min Hull Volume

Hulls computed with a volume smaller than this value will be approximated as box colliders.

Back Face Distance Factor

Set this to larger values on hollow objects for better results.

Force No Multithreading

Use this only if you experience hangs during the hull computation.

Normalize input mesh

This overrides the "Internal Scale" parameter. The mesh will be internally processed to fit a unit length sphere. Usually this doesn't improve the result but in some specific cases it can.

Compute Hull(s)

Starts the hull generation process. All hulls will be added as children of the GameObject and specified as colliders through the collider components.

Delete Hull(s)

Removes all generated colliders.

Is Trigger

Changes the "Is Trigger" property of all colliders. Check the Unit3D documentation for more information about what this parameter does (https://docs.unity3d.com/Documentation/Components/class-MeshCollider.html).

Material

Changes the physics material property of all colliders. Check the Unity3D documentation for information about what this parameter does (https://docs.unity3d.com/Documentation/Components/class-MeshCollider.html).

Smooth Sphere Collisions

Changes the "Smooth Sphere Collisions" property of all mesh colliders. Check the Unity3D documentation for information about what this parameter does (https://docs.unity3d.com/Documentation/Components/class-MeshCollider.html).

Troubleshooting

The component does not generate correct results

Some cases have been found where the algorithm does not work correctly, especially on complex objects with hollow parts. If this happens and tweaking the "Back Face Distance Factor" does not solve the problem, we recommend trying the alternative algorithm using the "Use Legacy Method" option. Also subdividing the object (separating composite meshes etc.) will help to generate more accurate results.

When I create a prefab and drag it back to the level editor or instance a gameobject using the concave collider, the hulls don't appear.

Enable the "Enable Prefab Usage" parameter. This will save the hull meshes to disk and enable to instance them correctly.

The process hangs during the hull computation.

Most of the times what actually happens is the process takes some time to update. If you are really sure the process hangs try using the "Force No Multithreading" option. The plugin has been thoroughly tested but since multithreading is involved and each case is different one never knows.

After the hull computation, Unity3D says a convex collider can have a maximum number of "x" triangles.

Although there is no direct control over the maximum number of triangles generated, decreasing the "Max Hull Vertices" property will reduce the number of triangles as well. You can check the maximum number of triangles computed for a hull on the information provided above the "Compute hull(s)" and "Delete hull(s)" buttons. Also, using the "Output Debug Messages" option, additional helpful information is written on the console window after each computation.

After computing the hulls Unity3D says "Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!"

One or more hulls have been generated with near zero volume. This probably happened as a result of processing a very complex object. The solution to this is to activate the "Output Debug Messages" property on the Concave Collider component panel and run the computation again to see which one of the hulls is triggering the error. Check its volume on the console window and then set the "Min Hull Volume" to a value just slightly higher than this volume. The next time the hulls are computed, the problematic hull will be approximated as a box and hopefully the error will disappear.

Acknowledgements