Use GDScript to create collision mesh for my procedural generated 3D terrain.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Whitefame


I have generated a procedural 3d terrain with the SurfaceTool and now I want to add collision to it. Before 3.1 I could use “create_trimesh_collision/create_convex_collision” to generate one but after 3.1 i get that “Method ‘create_trimesh_collision’ is not declared in the current class”.

Do any of you know how I can generate a collision mesh to my procedural terrain using GDScript?

These methods still exist for Meshinstance:
MeshInstance — Godot Engine (3.1) documentation in English

Does that help?

wombatstampede | 2019-06-26 15:02

Thats how I’m using it. But gets the above error.

Whitefame | 2019-06-26 17:06

:bust_in_silhouette: Reply From: KijeviGombooc

I used MeshInstance.create_trimesh_collision(), jsut today, and it worked well:

var meshInst =
.#adding vertices, uvs and stuff to SurfaceTool
meshInst.mesh = st.commit()

In this code the MeshInstance itself was created in code too, but you can use an existing MeshInstancetoo, of course