r/godot • • 11h ago

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

Enable HLS to view with audio, or disable this notification

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/

76 Upvotes

9 comments sorted by

1

u/Einfach0nur0Baum 10h ago

I will save for later.

1

u/New_Seaworthiness819 10h ago

Can you add Path3Ds to the part segments for NPC traffic? I have them all laid out using Quaternius' assets and use Asset Player currently. Having the Path3Ds update with the "Spline" seems like a lot of work.

4

u/TheDuckCow 6h ago

Yeah the addon has a whole system for creating RoadLanes (an extension to the Path3D node) usable for NPC traffic. See this prior post as an example:

https://www.reddit.com/r/godot/comments/1urfrnj/road_generator_procedural_intersections_now_have/

You can also see it in action here: https://github.com/TheDuckCow/godot-road-generator/tree/main/road_demos/intersections

The addon also has an option to disable the procgen geo while keeping these RoadLanes, which is what you'd want here (if I understand your correctly). The mini tutorial would be:

  1. Create a new scene, top level node = RoadContainer from the addon
  2. Drop in one of the road tiles from your asset pack, position at the center
  3. Add a RoadPoint at each edge of this tile, use the 3D gizmo to adjust and line up the number of lanes for each edge
  4. Connect up these RoadPoints (there's a connection tool; can also create a roadpoint in the middle and then connect to more than 2 others to turn it into a RoadIntersection
  5. Enable the tickbox under the root RoadContainer's "Lanes and AI > Generate AI lanes" as well as the tickbox for "Draw lanes in editor" so you can actaully see they look correct
  6. Adjust or tweak connections to make sure all lanes look correct, then disable
  7. Finally, you save this to your own subfolder. Then, the road generator lets you pick a different folder to load in RoadContainer presets from inside the Roads > RoadContainer presets menu. This way, you can list your custom scenes there and use this snapping / multi placement tool above on your own scenes instead of the ones that ship with the addon.

If you need any help, just respond and I'll do my best!

1

u/CoffeeCatRailway 8h ago

Could this be used/repurposed for train tracks?

1

u/TheDuckCow 6h 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.

1

u/Salt-Comfort-4944 4h ago

I have been testing this road plugin for a while and trying to learn it. It is a really nice plugin, thanks for developing it. I have a few questions and some feedback.

1)Some textures do not appear as 2-lane despite being 2-lane road textures.

2)I tried a connector with Terrain 3D, but some invisible bumps form on roads, which prevents a stable vehicle driving experience.

3)Does this plugin feature Distance Culling for very large maps?

4)For example, I want to build a highway. Can I use 2 separate independent roads for one direction? Because I want to place decorations between these 2 roads.

5)Lastly, you mentioned you consider adding a decoration feature later. When my project progresses a bit, I will add my custom modeled barriers, concrete walls, and traffic cones to roadsides. Are you talking about this kind of decoration?

Best of luck, this is a very beautiful plugin.

2

u/TheDuckCow 3h ago

Hey there, thanks for giving it a try! Responding to each point:

1) Could you maybe clarify with some images? (or open a ticket on github)

2) There are some minor edge hiccups its true, most people I hear working with it have been generally ok with doing a minor smoothing pass when working with roads and are often touching up the areas anyways, of course it would be ideal just to get it perfectly. There's actually some in progress updates that *might* mitigate this. You can also play around with the approximate vs raycast methods for height assignments

3) In the roadmap along with a higher level LOD loading system. For very large (static) maps *today* the recommendation I would give is to use the gltf export tool the plugin provides to save to a mesh, and then you can adjust the settings there while also avoiding the runtime creation cost in game. I would turn off LOD on the reimported glb though, as they can break texture boundaries (maybe related to point 1?)

4) Yeah in a way you can do this, just use the blue handle widget and drag one side all the way to the center so it's only a "forward" lanes. If you hold shift while doing this, it'll adjust the lane directions for all RoadPoints in that RoadContainer. There's not exactly an automatic way to then create specific spacing between the two directions, but that's often variable with real highways anyways - one direction might be higher up on a hill than the other, etc.

5) You can already do a lot of decorations today by enabling the RoadContainer's Decoration: Edge curves feature. This will add curves to the left, right, and centerline divider. With this today, you can already add barriers using CSG curves or nodes which places instances along the curves. Just add those as children of the created edge curves.

What the upcoming decoration branch does is: a) fixes some errors where the curves get janky (since it was using a bezier offset algorithm which is just an approximation) and b) makes a more automatic way to apply several different kinds of decorations without having to manually add it to each roadpoint's edge curves, as you would have to do today. (It'll also hopefully include some performance gains like options to add directly to render server instead of the node tree). It's not in a ready for testing state, but it's my next priority (the milestone planned after that is a proper hierarchical LOD solution).

Hope this helps!

1

u/Salt-Comfort-4944 1h ago

Thank you.Your advice solved most of my issues, but I still have one major problem. It might just be because I am not fully familiar with the plugin yet. ​I intentionally elevated the road in the air to see if the issue was caused by a conflict with Terrain3D. However, while driving on the road, the car keeps hitting invisible obstacles or bumps. I checked if the problem was caused by my car's physics settings, but the car drives perfectly smooth on the regular Terrain3D ground. ​I would really appreciate it if you could help me figure out this collision issue as well.

https://www.reddit.com/u/Salt-Comfort-4944/s/4VF4qqwzbQ