cables! (and a quick guide on csg paths in godot)

I learned how to add procedural geometry to no signal using Godot’s built-in CSG tools and now I have wires and cables everywhere! :sparkles:


I also wrote a short guide on how to do this, which I’ll share below.


In Godot, first add a Path3D and give it a curve. Remember that you can use an orthographic view to make it easier to move and place new points on the curve!

Next, you’ll want to add a CSGPolygon3D. It represents a 2D shape that will be extruded to create a 3D one. Go ahead and customize the shape if you want to. In the screenshots I showed in the earlier post, I wrote a script that generates a circle, but for this example I’ll keep using the default square shape.

Then, change the mode to Path and set the path_node to the Path3D we created earlier:

And there you go! It kind of looks like an air duct. You can play around with the path settings in the CSGPolygon3D to get the shape/divisions you want.

2 Likes

Oh that’s really impressive. Do you add the “u shape that maintain them against ground” proceduraly as well ?

I don’t spawn the cable clamps that way, but you could! The Godot Curve3D API makes it possible to write a script that places an object along the path every so often. It would look something like this:

const INTERVAL: float = 0.5

@onready var path: Path3D = $Path3D
@export var item_scene: PackedScene

func _ready() -> void:
	var distance: float = INTERVAL
	while distance < path.curve.get_baked_length():
		var pos: Vector3 = path.curve.sample_baked(distance)
		spawn(pos)
		distance += INTERVAL

func spawn(pos: Vector3) -> void:
	var item: Node3D = item_scene.instantiate()
	item.position = pos
	add_child(item)
1 Like

Okay I see! It’s quite smart!

I should take some time to use Path3D, need to use it for some cutscene as well. I’m sure I could find more uses as I get more comfortable with it.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.