How to subtract a intersection between two meshes in GDSCRIPT

Attention Topic was automatically imported from the old Question2Answer platform.

I’m aiming create a house procedural generator, for now I can create 4 walls in a rectangle shape, here is the code:

``````var myMesh = MeshInstance.new()
myMesh.mesh = CubeMesh.new()
myMesh.mesh.size = Vector3(x, y, wall_thickness)
myMesh.create_trimesh_collision()

var myMesh2 = MeshInstance.new()
myMesh2.mesh = CubeMesh.new()
myMesh2.mesh.size = Vector3(x, y, wall_thickness)
myMesh2.translate(Vector3(0, 0, z))
myMesh2.create_trimesh_collision()

var myMesh3 = MeshInstance.new()
myMesh3.mesh = CubeMesh.new()
myMesh3.mesh.size = Vector3(wall_thickness, y, z)
myMesh3.translate(Vector3(x/2, 0, z/2))
myMesh3.create_trimesh_collision()

var myMesh4 = myMesh3.duplicate()
myMesh4.translate(Vector3(-x, 0, 0))
myMesh4.create_trimesh_collision()

``````

Now I want to add doors but I can’t find out a manner to do that, the best way I tought of was to subract the door passage and then add the door mesh, but don’t find any exemple for mesh subtraction in code

You can use a GSGcombiner with it’s children as CSGboxes (and other GSGshapes).

Thanks, here is an example in code, I added in the CSGcombiner node script

``````	var wall = CSGBox.new()
wall.width = x
wall.height = y
wall.depth = 0.2
wall.translate(Vector3(0, y/2, 0))