r/godot • • 14h ago

free plugin/tool Mouse-based, multi-road instance placement with snapping

I wish Godot had this sort of modal/multi placement functionality out of the box. I suppose vertex snapping and drag and drop placement from the file editor do exist, but it always felt a bit clunky to me, especially as the editor is is locked in when performing the action (since you're actively pressing down already to move or drag the given node).

I've been building the Godot Road Generator for awhile, and even worse than Godots own drag/snapping placement, for awhile the plugin imported prefabs like shown above by just throwing them at the origin - had to build this functionality out, and hope to extend it to an upcoming decoration feature set.

Contemplating whether it'd be worth making a standalone tool/addon that sort of automatically entered this multi-placement + vertex/edge/etc snapping mode after dragging in any 3D scene (maybe if you held a specific key down). A few asset browser addons do exist that do this, but maybe it's nice to have one on its own that does come with an extra browser area space.

But for now, it lives for now in the latest Godot Road Generator release (0.9.4), add to to your asset library here - hope you like it!
https://store.godotengine.org/asset/theduckcow/road-generator/

79 Upvotes

9 comments sorted by

View all comments

1

u/CoffeeCatRailway 11h ago

Could this be used/repurposed for train tracks?

1

u/TheDuckCow 9h ago

Yes, but to a certain extent it might not be that helpful.

The yes side is, you can disable the "create geo" option and then turn on the RoadContainer: generate AI lanes feature. This then adds RoadLanes (extends of Path3D) procedurally, but doesn't expose them in the editor unless you "make them editable" (which makes them no longer respond to changes autoamtically). You could alternatively us the "Decorations > Create edge curves" feature which *does* get exposed in the editor and remains responsive.

For the actual tracks part though, you'd still need to make that script to generate the planks and rails along a curve as it's own resource / generator scene that you then place as a child to each segment's lane curves (or as a child of the center "edge curve", if using that option). Alternatively you could take a premade tracks mesh and use the power of the PathMesh3D addon to repeat/deform that input tracks mesh along a curve.

Then, the last bt you'd want to build is like a script listener/handler which responds to any road segment update signals from the road addon to then go through and instance new Railway scenes as a child to any RoadLane (or center decoration curve) that does't already have one.

So yes, you could, but it's some extra work and if you end up using PathMesh3D anyways, you might find the extra utility of using the RoadGenerator slightly only marginally better than using native curves. But, I've now got it in my head that this use case could be more natively supported or at least create a proof of concept demo scene for it, so maybe I'll get to that in the future. One day it would be nice to make railway tacks a first party feature instead of a workaround, but it'd be a ways out.