![]() |
Universal Colliders 1.2.0
Generate fast and accurate colliders for Unity
|
Welcome to the universal colliders' documentation!
The Universal Colliders was developed to put an end to the "non-convex collider" problem in Unity. Its goal is to generate colliders dynamically, with a robust method yet flexible and controllable by the end-user or scripts.
This project stems from the object-oriented bounding boxes algorithm, as defined in the 1996 paper OBBTree: A Hierarchical Structure for Rapid Interference Detection. Is is more precise than the AABB-type algorithms, axis-aligned bounding boxes, easily found on the marketplace. It was also developped to be flexible, and to provide as much control as the "user-paint" type algorithms. We extended it to user shapes such as mesh colliders, making it the ultimate tool for colliders generation.
The basic workflow is simple: choose an object, add the UCollidersRoot component, change the recursion level, and launch the scene. This section goes into a detailed explanation.
This section is a short manual to use this script. Please see the related section for the script reference.
First you need a model with a mesh with "Read/Write Enabled" set to true in the mesh's options. Then simply drag the "UCollidersRoot" script as a component, and choose the recursion level with the slider.
When you reach necessary precision, just start the scene, and a set of bounding boxes will be generated as children of an empty GameObject. You are all set!
The next field it the kind of vizualization you want to have. Choose anything convenient, but keep in mind it is only here for debug and does not modify the scene.
The "include children meshes" property changes the meshes taken into account. By default, we only use the MeshFilter of the associated object, ignoring its children. In some cases you may want to include them in the collisions as well, so check this box if required.
The colliders' shape field allows you to switch to another kind of shape than a box. By default, we generate oriented minimal bounding boxes. It means that each vertex is enclosed in a box collider. However, it may give inaccurate results when you set a low precision. One solution is to use a higher recursion level. You may also want to change the shape of colliders to spheres, cylinders or mesh.
The way colliders wrap around the mesh. If boundicity is 0, shape will be inside the mesh. With boundicity of 1, mesh is contained in the collider.
Colliders encapsulate triangles instead of single vertices. Slower but avoid holes around edges.
By default, the script uses vertices only to compute colliders. However it is troublesome with meshes with long edges. Use this option to consider entire triangles (vertices + edges) instead of vertices only.
Note that holes will be avoided, but convergence becomes slower.
This button generates the UCollidersNode objects without waiting for the scene to start. In case some colliders have already been generated, they will be erased, unless they have the "preserve collider" property checked.
This button will convert UColliderLeaf children into standard colliders GameObjects. It is equivalent to deleting UColliderLeaf components from children manually, though this button also flushes out the data.
Flush all the data, and removes associated colliders. Useful for correcting mistakes.
This is automatically added as a component to mark that a GameObject is in fact a UCollider. You may interact with it, but adding it manually is not supported.
If checked, this UcolliderNode won't be deleted when you hit the "Regenerate Colliders" on his parent.
The exact analogous of shape in UCollidersRoot, but applies for this specific UColliderOnly.
Sometimes a computer is just not enough and you need a human. If a specific UColliderNode gives a result too coarse for you, you may force its subdivision manually.
This field is simply the list of vertices that shoud be enclosed. You can view it freely but take care as it can be ver long and slows down Unity.
OBB stands for oriented bounding box. It is oriented in the way that the OBB rotates to match the approximate "direction" of vertices. On the opposite, methods such as axis-aligned bounding boxes does not apply rotations, creating much bigger boxes.
As a general assertion, Universal Colliders performs well on high-poly mesh. If you have no control on your mesh, this section may help you.
If the generated colliders are inaccurate, here is a solution. The basic workflow to add more precision is:
This means your vertices are not very random, so Universal Colliders optimizes colliders by following diagonals. Either makes vertices more random, or try to use the "encapsulateTriangles" property.
The only scripts you may interact with are UCollidersRoot.cs and UCollidersLeaf.cs. The other script provide various useful functions for the code to work. In case you need them in your code, you can find them under the namespace UColliders
.
The Suzanne model is a standard object generated by Blender. According to Blender's licence terms this model is considered as a part of this package.
Math.NET Numerics is a library for numerical computation under MIT License. It is used as a complete library for matrices.
The main logo of the project is an original creation of Florian.LB. The logo and his variations are a property of this project.
We created this package because we thought the marketplace was lacking a robust colliders package. The project went well, so you are welcome to make propositions of future developments.
If you encounter any problem, want an enhancement, and so on, please join the Discord community. If you enjoyed the package, please let me a review. I made this package because I thought it could be useful, it took me a lot of time for an uncertain result.
The email address for this project is universalcolliders@houmgaor.com. Get in touch!
You can also leave a comment on the website (no email required) https://www.houmgaor.com/.
Enjoy!