Using a DAE mesh for collision

Here’s a quick guide to converting your DAE mesh into collision objects using Blender and dae2collision.


This has only been tested with a simple model from Blender 2.93 using (probably) default settings. Other setups will hopefully work, but no guarantees.

Preparing The Model

Since Defold doesn’t support concave collision shapes, we’ll need to split our model into convex pieces. This, unfortunately, must be done manually, as I haven’t found a working way to automate it. To split a mesh in Blender, you can simply select a part of it in Edit mode, press P, then hit Selection to move that part of the mesh to a new object.

It should look something like this when you’re done:

Since Defold also doesn’t support rendering multiple objects in a mesh, you need a single-object version of your mesh for visuals and a split version for collision.

Now that we’ve got a nicely formatted model, let’s head over to the editor for the easier part.

Using dae2collision

Go ahead and put your new model somewhere in your project (if it’s a particularly complex one, I recommend giving it its own folder) and add dae2collision to your dependencies. It’s a small module meant to be used by an editor script, but it doesn’t come with one. Instead, you can copy the example editor script and tweak the properties to fit your game. Now (assuming you’re using the example), right-click a .dae file and select Generate Collision and it will create one .convexshape per object in the mesh, as well as a game object that puts them all together:

Finally, just add *_generated.go to your game and you’re done!



Thank you so much for this script! As a continuation of the topic, I will add here a link to the excellent 3d level editor, which is completely suitable for creating levels without concave collision shapes - TrenchBroom. It has export in obj format for further conversion in Blender (checked).


Thank you for the great tool!

While making a 3d game with Defold, I found that Bullet Physics has a parameter named “Collision Margin”. Its value is 0.04 in Defold. Why? Take a look at the Bullet Physics manual:

You should take it into account if you are going to use custom collision shapes in Defold. In Blender, you can use the Shrinkwrap modifier that has the “Offset” parameter.

Without that, there is a noticeable offset between physical objects: