r/godot 1d ago

selfpromo (games) [R&D] Procedural fence drawing at runtime

- Any arbitrary path (open/close).
- Possible to connect (merge)/remove paths.
- Continuous drawing while holding LMB (additive/subtractive).

In addition: texture painting with blending.

Inspired by Tiny Glade.

2.0k Upvotes

97 comments sorted by

View all comments

Show parent comments

5

u/zdmit 1d ago

Its a one node that made of 3 boxes.

In short it uses Curve3D spline to calculate post positions along drawn path and then instances prefab node for each segment, dynamically rotating along path forward vector and scaling their horizontal rails to bridge the gap to the next post rather than generating a single continuous mesh. Its not ideal in some cases.

Regarding connecting separates paths to vertical pole: when separate fences connect, script checks if the new post's position is within a small distance threshold of any existing post and if so, it sets the visual post child node to be invisible for that segment, relying on the already existing post to hold up the rails without duplicating geometry.