TheDuckCow / godot-road-generator

A godot plugin for creating 3D highways and streets.
MIT License
313 stars 16 forks source link

Add Custom Roads #97

Closed Renan02938 closed 2 months ago

Renan02938 commented 1 year ago

Create road networks by importing your own models

TheDuckCow commented 1 year ago

Hi @Renan02938 thanks for chiming in with this use case.

If you mean having sections that are pre-modeled (such as hand crafted meshes, or prefab scenes already laid out in a scene), then yes this should in fact already be possible - it's a core use case in the Wheel Steal game we are making this for. But at the v0.3.2 point of the plugin, it is somewhat awkward. We will create a page around it soon, but in short:

Video overview

https://github.com/TheDuckCow/godot-road-generator/assets/2958461/494fe3f2-6e44-45f8-8008-e422ab51faeb

Step by step

  1. Import your hand-crafted model into its own scene (being in its own scene just makes it reusable, you could also just do this in the "main" scene with your RoadNetwork)
  2. Manually place RoadPoints with the correct number of lanes for each end point of your custom mesh. Do NOT connect them together, otherwise geometry would be created between them. I should have reduce the "shoulder size" to zero on both points in this demo, since the mesh basically has no shoulders.
  3. Optional (not shown in video): If you're using the generated AI lanes with the rest of the road, you'll need to manually place "RoadSegment" curves which follow each lane that you'd like AI to be able to follow. Note that the the AI lane system is pretty basic right now and leaves most of the work to the user at the moment to make useful, it will be getting better.
  4. Bring your custom scene into your scene with the rest of the road network
  5. Mark the instance as "editable children" (this is not necessary if you are making these connections on the fly during the runtime of the game)
  6. Then, manually connect the according "prior points" to "next points".
  7. Tweak the sizes of the roadpoint as necessary (in the video, I did this on the "editable children", I should have done this in the original scene itself to save rework on reusing this piece).

Note: Connecting two custom segments like this right now likely won't work, as the RoadNetwork just looks for RoadPoints to generate meshes for which are children of the Points spatial. So if you are hoping to use exclusively models you've created yourself as a sort of lego block of piecing things together, it won't work very nicely (it's also not going to be that useful to use the plugin anyways, other than eventually making use of the smart placement tools we are planning to build).

Note 2: We are indeed hoping to make this experience even easier, as this is our strategy for how we'll implement off the shelf complex road configurations and intersections, so users won't have to build it all themselves each time.

Hope this helps! Let me know if you were thinking of something different.

TheDuckCow commented 1 year ago

Sorry one more follow up to this topic. I realized that my demo scene here had it working, but the released code has some "validators" that actual make the roads disconnected. Your workaround in the meantime is to disable the "auto refresh" setting on the RoadNetwork, and on runtime call the function on the network called "rebuild_segments". But I realize that's not great to work with and doesn't become visible in the UI.

So, I'm marking this a bit more explicitly as an open task to do. The implicit requirement is to allow for nested scenes to work better (let the validator pass), and to create tools to make it easier to connect to different road points in the 3D viewport, and not have to fiddle with the inspector panel.

TheDuckCow commented 1 year ago

Also flagging this video I think you had initially shared in one of your earlier videos, it makes a compelling case for letting the user specify their own geometry to be curve-deformed, which is an interesting case (doesn't especially meld well with our use cases of having flexible lane selections, but something for us to consider nonetheless):

https://www.youtube.com/watch?v=EiFkNPcQVc0

TheDuckCow commented 2 months ago

I'm going to mark this task as done, as we now have pretty robust tools for connecting different RoadContainers together since v0.4.0, though other ongoing efforts such as snapping referenced here will continue to make this even easier in the future. The curve deform is also a separate task now, defined here: https://github.com/TheDuckCow/godot-road-generator/issues/123