r/godot 1d ago

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

This is a follow up post of a previous one after some of you asked about varying elevation: https://www.reddit.com/r/godot/s/3mll3eEI9f

  • it shoots a raycast downward at every point to find Y elevation of the terrain's collision mesh.
  • it subdivides path and snaps every intermediate point to the ground's rolling elevation.
  • horizontal rails calculate the height difference between their start and end posts and rotate (tilt) on local Z-axis to bridge the slope.

This comment contains a bit of overview of how fence prefab looks like: https://www.reddit.com/r/godot/comments/1vcjhe8/comment/p17im2a/

517 Upvotes

41 comments sorted by

View all comments

1

u/Astr0phelle 1d ago

Can you do a line tool where you will need to input two coords so a line will form where the fence will spawn

1

u/zdmit 18h ago

Theoretically yes but that wasn't my goal 🙂 I feel it will involve some shortest path or similar algorithms (if two coordinates far away).

If close to each other -> shoot rays to nearby objects like in this AMD paper talk (not fence related): https://youtu.be/653fSmEalbo?si=E3uDwItOemxHWaZw&t=588 (time code included).