I want 3d terrain with collisions. what are my options?

I agree that a single convex hull is not a good fit for terrain. It will wrap the whole shape and fill in concave areas, which is why you get that large artificial slope.

At the moment, Defold does not expose such an advanced built-in terrain collider workflow in the editor. The built-in options are primitive shapes and convex hulls. Convex hull generation tools can help with some models, but they do not solve the terrain case by themselves, because the terrain is usually concave.

Some ideas you can try:

  1. Use the terrain mesh only for rendering, and build a separate simplified collision representation from boxes/capsules/spheres/convex hulls. For this to work with non-convex level geometry, the collision mesh has to be split into smaller convex pieces.

  2. For a heightmap-style terrain, handle terrain collision yourself instead of relying on the physics engine. Sample the height at the character’s (X,Z) position, set or constrain the character’s Y position, calculate the ground normal from nearby samples, and handle movement in the character controller. This is often the best approach, especially if you mostly need it for characters movement rather than full rigid body complex and realistic simulation.

  3. Generate chunked collision from the terrain: for example small convex patches, boxes, ramps, or simplified tile-like collision pieces and put them in your game like a grid based tile map.

  4. Use a native extension for a custom physics solution. There has been work on alternative physics extensions like ReactPhysics3D by @d954mas

Also note that since 1.13.0 the deprecated .dae (Collada) support is removed.

For the future, we already had put some effort into making custom data components in Defold that will be now first battle tested with light components in the upcoming 1.13.1. We are also working further on Editor extensxibility. These together are planned to be used to creat such solutions similar to terrain editors in other game engines. But that is a vision for now, that we’ll be shaping.

7 Likes