This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

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 =
myMesh.mesh =
myMesh.mesh.size = Vector3(x, y, wall_thickness)

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


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


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


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

Godot version 3.3.2
in Engine by (76 points)

1 Answer

0 votes

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

by (248 points)

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

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


var door_passage =
door_passage.width = 2
door_passage.height = 4
door_passage.depth = 1
door_passage.operation = OPERATION_SUBTRACTION 
door_passage.translate(Vector3(0, door_passage.height/2, 0))    
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.