MCOL (Mesh colliders) - kagenocookie/ReachForGodot GitHub Wiki
MCOL - Mesh collider / collision meshes are usually used for static level collisions and for VFX collisions. They contain one mesh of any size and possibly many additional primitive colliders (spheres, capsules and boxes). The file format itself also contains a BVH for fast lookups, these get automatically handled by the addon so there's no need to worry about that.
Each mcol also contains 1 or more physics material tags / layers. These are defined as strings separated with __
.
Editing
Any mcol resource is imported with two accompanying files - a mesh for the collision mesh (created as .glb on import, but any Godot supported mesh format should be useable), and a .tscn file containing all the primitive colliders (since blender doesn't have real support for them). The main resource also contains the list of materials.
In general, all you need to do is modify the mesh and/or colliders in the scene and it should just get handled fine when exporting back to mcol format. So the expected workflow:
- Import the mcol file (automatically done for any mcol linked from a .scn file)
- Next to the mcol resource there's also a mesh .glb and a .tscn file, both of these described further below
- Once you've done all your desired changes, select the .mcol.tres file or the root node inside the .mcol.tscn and export it to your game / mod folder
Mesh
The mcol mesh, beside the actual geometry, also holds some extra information, though most of the time you likely won't need to care about these. Each mesh material corresponds to a mcol physics material. Vertex colors are used to hold the collision masks of the geometry, although from the games that I've tested this is always just white (0xffffffff / -1). UV coordinates are used to store some additional mcol specific data - the X coordinate represents the mesh part ID (used in mcol versions >= 20021, probably for conditionally disabling parts of the collider). It's multiplied by 256 to get it in the 0-255 integer range before exporting. The Y coordinate is currently irrelevant.
- Import the .glb into blender
- Make any changes
- Export it back from blender into .glb and replace the original .glb file with it
- Theoretically, any mesh file format should work if you assign it to the MeshCollider resource's Mesh field, but only glb is tested for
- For in-scene 3d preview, if you select the Collider__MeshShape object, there's a "Refresh mesh shape" button to force it to refresh. (Note that it seems like Godot is caching the mesh sometimes so you may need to reopen the project to make it actually update again - Project > Reopen Current Project)
- You can also open the .mcol.tscn file where it's usually displayed correctly
Colliders
To edit the colliders, just open up the .mcol.tscn file and move/add the nodes under the Colliders
node. Only spheres, capsules and boxes are supported here. The additional mcol parameters are encoded into the node name here, in the format NodeType__i{layerIndex}__m{mask}__p{partId}
; if these are not found, default values of 0, -1 and 0 are used respectively.