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.
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)