Using a DAE mesh for collision

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

Note

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!

Finished!

17 Likes