How To Build Roads Procedurally In Unity with the Splines Package

Sdílet
Vložit
  • čas přidán 28. 08. 2024

Komentáře • 78

  • @realtimberstalker
    @realtimberstalker Před rokem +36

    If you would like to make the curves for the intersection flush with the sides of the road, you can find out where the lines intersect, and set that as the point for the Bézier curve, which will give you a smooth transition.

  • @CaseyHofland
    @CaseyHofland Před rokem +11

    I love how you start with doing your research, how you use existing API's, how you solve problems in a "leave everything untouched" manner: I'm still screaming to developers we should all be doing this, and it's nice to watch someone use these tools so effectively and cleanly. Subbed!

    • @lukasfletcher4732
      @lukasfletcher4732 Před 11 měsíci +3

      A bit late but could you clarify for me what you mean by "leave everything untouched"?

    • @aceman0000099
      @aceman0000099 Před 12 dny

      ​@@lukasfletcher4732 I think he means, e.g. when he created an extension to the unity class rather than try and alter it and break the consistency.

  • @v0ltdev
    @v0ltdev Před rokem +5

    Oh my god you saved me, you have no idea how much i tried to figure out how can you do roads with this spline package

  • @spidermankey1398
    @spidermankey1398 Před rokem +11

    Ah! Another most learning video by this absolutely astonishing guy. Love this channel!

  • @v0ltdev
    @v0ltdev Před rokem +19

    Ok, I tried following this tutorial but I'm having a rly hard time doing it because there is a lot of stuff you don't show, for example the functions from the overlay class or create new variables or parameters to functions and not even show or mention them, create structs but not showing where they are placed, etc.. I was finally excited to see how to make roads with this package cuz there is no other tutorials on how to do it, but you're making it hard by not showing everything.

    • @JoseALugoR
      @JoseALugoR Před rokem +6

      Yes the same happened to me, even though he explains the concepts amazingly he pursposefully is not clear on some things of the code that you have to try to figure out for yourself or pay for his patreon and download the code... love his content but this video made me waste time trying to figure out the code.

    • @v0ltdev
      @v0ltdev Před rokem +2

      @@JoseALugoR i managed to figure it out and do the roads without the intersections, if you want i can send you the script

    • @JoseALugoR
      @JoseALugoR Před rokem +4

      @@v0ltdev thanks but I worked through it and got the intersections to work, don't need it now 👍🏻

    • @v0ltdev
      @v0ltdev Před rokem +4

      @@JoseALugoR oh, then if you dont mind could you share how you made the intersections work?

    • @itsosmx
      @itsosmx Před rokem

      I know it's been a while, but can you send the code?@@v0ltdev

  • @enescagrbayraktutan6329
    @enescagrbayraktutan6329 Před rokem +5

    Awesome video tutorial! It would be amazing if you make traffic system for this procedurally generated roads in next videos! Keep up the good work!

  • @matheussantos250
    @matheussantos250 Před rokem +3

    I was literally researching to do this two days ago. Thanks for the amazing as always

  • @zORg_alex
    @zORg_alex Před rokem +3

    And here am I, who spent a year making my own easy to use spline package. I felt I needed to fill that gap in Assetstore. Although there were some spline packages already, they all were Monobehavour based. I wanted a spline as a serialized object with it's own editor built into property drawer. But now we have this.
    But I think I still have more features in my BezierZ.

    • @stickguy9109
      @stickguy9109 Před rokem

      I wish we had something similar to blender's curve tool with modifiers and everything.

    • @zORg_alex
      @zORg_alex Před rokem

      @@stickguy9109 well modifiers I did not. But I've started some mesh generation tools. Like bending existing mesh along a path, or generating mesh from profile or another curve as profile. But my curve has interpolation built into it. So I might do it as a separate class so it would be more versatile.

    • @feathorix8778
      @feathorix8778 Před rokem

      Oh, I feel you. Okay, I didn't write a whole asset from scratch, but I picked up the SplineMesh asset like 10 months ago and rewrote it heavily so that it uses Burst and jobs because I needed quite good performance for the mesh generation.
      Then I had a look at Unity's asset and recognized that it would be too much work for me to switch the spline asset 🥴😆.

  • @nocturne6320
    @nocturne6320 Před rokem +7

    I cannot imagine how complex the system must be in Cities Skylines

  • @Samuel-bd1ms
    @Samuel-bd1ms Před rokem +1

    Wow. You just blew my mind with that Unity asmdef hack.... I'm going to use this in every project.

  • @domkalan
    @domkalan Před rokem +3

    Amazing video, I’m currently doing my own research on this topic for a city building prototype I am working on. I have come to the conclusion that splines are the best method, and then looping through the spline points would be the best for pathfinding which splines are the best route to take.

  • @asr59
    @asr59 Před 3 měsíci

    Very interesting video! I've been working on a road system in Houdini for a game and nice to see other peers have gone through the same issues and solutions :D

  • @nxt_tim
    @nxt_tim Před rokem +3

    This came at the perfect time 😊 Been wondering on how to approach this because of an upcoming game jam.

  • @JustDezz
    @JustDezz Před rokem

    This assembly definition hack is so much simpler than reflection mess. Thank you!

  • @shadow_xts
    @shadow_xts Před rokem

    Thank you, I wasn’t aware of the Splines package. I had written splines myself to procedurally generate meshes and the least I can say, visualization wasn’t great. I now need roads that exist in 3D space and have colliders to it, so I’ll adapt this to procedurally create the colliding meshes. Thank you so much!

  • @GamerChunkZ
    @GamerChunkZ Před rokem +1

    Wow. Looking more into these kind of terrain and road generation tool videos.

  • @grahamreid876
    @grahamreid876 Před rokem +1

    This was so helpful! I never even thought to use splines like this 🔥

  • @TNTCProject
    @TNTCProject Před rokem

    Terrific! As someone who is fascinated with pcg, I absolutely loved watching this. Good job :)

  • @matthiasallner4610
    @matthiasallner4610 Před 11 měsíci

    Really cool video as always. I am working on a similar system, but bigger and even more procedural with houdini and if your brave enough to start with houdini i can tell you the sweep node is your friend! With it i generate one or multiple crosssection(s) of a road and "sweep" them along road splines and the result is a 3D modular RoadMesh that can be brought by HDA into any engine.

  • @Briglair
    @Briglair Před rokem

    Absolutely amazing! Concise and to the point. Thank you

  • @tokyowarfare6729
    @tokyowarfare6729 Před 4 měsíci

    Considering the queality of unity deliveries in lates years. The spline tool looks oddly well built and fully featured.

  • @adamodimattia
    @adamodimattia Před měsícem

    I don't think it is a "hacky" solution. The "internal" specifier is only there to ensure that no one will make use of internal api accidentally. There are also other ways around it, but these make use of relfection. The assembly reference is in fact quite a nice way for doing it.

  • @dreamisover9813
    @dreamisover9813 Před rokem +1

    Great to see a new upload! Some of the other videos from your channel have been my favourite in terms of Unity content/tutorials

  • @Sylfa
    @Sylfa Před rokem +1

    6:12 - I do believe you flipped left and right in this section. Not that it matters much for the video, and I doubt there's any tools in youtube for fixing something like that without replacing the video entirely which would be way overkill.

  • @fokeyjo
    @fokeyjo Před rokem

    This was a really great video, well worked out. I was looking into this for a project. I hadn't got that far (and I probably would've run away at the point it got to UV mapping 😆), but I thought it might be slightly simpler for working out the intersection mesh points by having the original spline lines joining at the intersections, because then you have the perfect centre point for the junction. All the road termination points would be known from that centre (each road ending just has a distance back along its spline, and I think you can calculate it as another poster points out) and you'd even know if they were concave/convex from the angle between them being over 90. I'm assuming the spline near the junction is pretty straight (I was doing this with straight lines coming into junctions).

  • @skope2055
    @skope2055 Před 3 měsíci

    Great content! Helped me a lot!)

  • @nay2d2
    @nay2d2 Před 10 měsíci +2

    cant get the gizmos part working, since I don't know what you did differently or didn't show that makes it work, really confused.

  • @krum3155
    @krum3155 Před rokem +1

    Why not use a bezier curve for the curves of the intersections aswell? Like having the points be the corner points and the tangent the directions of the roads.

  • @fx.minecraftgamer2370

    You are a true hero, this video helps a lot!

  • @sekunriruisen506
    @sekunriruisen506 Před 11 měsíci +1

    Do you have this code anywhere? Patreon or something? Cause I did my best to keep up with your video and could definitely not reproduce what you created. It's the first time following your videos that I couldn't come up with your outcome, it just felt like a lot was missing as I went through it and the Mesh just will not render for me.

    • @GameDevGuide
      @GameDevGuide  Před 11 měsíci

      Yep the project is available on Patreon 🙂

  • @IPv6Freely
    @IPv6Freely Před 11 měsíci

    Do you have a video that goes more into depth on the tree generation? That looks like it could be super useful for generating a lot of trees, especially now that Vegetation Studio Pro is no longer available.

  • @RollingHeat
    @RollingHeat Před 10 měsíci

    Great tutorial and 10/10 topic. Like'd and sub'd.

  • @user-cz4kb5uq9e
    @user-cz4kb5uq9e Před měsícem

    Technically in Houdini you'd do the same thing but using VEX instead of C#. There are, of course, some tools that allow to generate a spline base road without writing a code, but as soon as you go into all this junction stuff it's just much more efficient to generate it by code. So basically it is like replace C# code with the HUGE paid plugin to be able to do the same but in a different programming language 🤣.

  • @tomtomkowski7653
    @tomtomkowski7653 Před rokem +2

    This is the biggest nightmare of Unity.
    Something that should be given out of the box (and it is in other engines) you have to reinvent yourself like a wheel and then fight with the engine to make it work.
    Or of course, you can always buy a working asset from the store, how typical for Unity's new business model.
    Great video! Is not about you is about Unity.

    • @DatBoi-jc8jf
      @DatBoi-jc8jf Před 9 měsíci

      There's a free one called mb road system, it is somewhat limited but it can do 3d (like a cork screw for example) and allows you to use custom meshes, also it has navigation
      it does not use unity's splines because it's older than that, but it is pretty similar.
      I've used it for some school projects

  • @birahe1810
    @birahe1810 Před rokem

    It would be great if you could show about Cutscenes too!

  • @RaviGovender
    @RaviGovender Před 5 měsíci

    Hi there, this is great, thanks so much for the video! I have a question, and my knowledge of unity is very limited but Im thinking of developing an AR racing car game that uses splines to auto generate a mesh/race track in any indoor space. How I imagine this is the user scans their living room using their camera and the splines respond to the various pieces of furniture to create the race track. From what I get here in your video, the splines still need to be built and cannot just procedurally sort of 'spawn'? Am I correct in this assertion? Also do you think this would be possible for me to do like you without using houdini?
    Thank you!

  • @joeltumelty
    @joeltumelty Před 8 měsíci

    I've followed the video through to 9:45 and am stuck on implementing the JunctionBuilderOverlay class. Struggling with what needs to go in the CreatePanel and selection methods?

  • @majort9703
    @majort9703 Před rokem +11

    Amazing! but paywalled files :(

  • @RasmusMolck
    @RasmusMolck Před rokem

    Hey nice video, I have a question: Is it possible to place knots with the spline draw tool without having 3d colliders in scene? I find it very enoying in my 2d game that I can't place the knots with the draw tool without first setting up some 3d geometry.

  • @vladalx8820
    @vladalx8820 Před rokem

    Hi, what font and theme do you use on visual studio? Thanks!

  • @itsosmx
    @itsosmx Před rokem

    I really appreciate your work, but the problem with me is that you are shown the code in a very hard way to understand, and for me, I couldn't connect everything together, all we need just try to show us while you are writing or the full code editor screen, thank you for your hard work.

  • @nowherefool5869
    @nowherefool5869 Před rokem

    do you have a tutorial how to wrap this spline roads onto a spherical planetary surface?
    also, can you edit the splines during the game's run time?

  • @vivekpattnayak8443
    @vivekpattnayak8443 Před rokem +2

    Can someone guide that what SampleSpineWidth fuunction is?? and what does the t parametre does

    • @GameDevGuide
      @GameDevGuide  Před rokem +1

      That was just a wrapper function for sampling the point on the spline.
      T is just the time variable between 0 and 1 (like with a lerp function) zero being the start of the spline, one being the end of the spline.

    • @vivekpattnayak8443
      @vivekpattnayak8443 Před rokem +1

      @@GameDevGuide Thanks very much I figured about t
      sorry for further trouble do you mind how does this wrapper function works

    • @sphelelelubanyana1750
      @sphelelelubanyana1750 Před 7 měsíci

      Nice

  • @raikenleo1902
    @raikenleo1902 Před 2 měsíci

    how do you open the spline in the code editor?

  • @luisportilla4109
    @luisportilla4109 Před 11 měsíci

    where did the sphere come from in the spline sampler script

  • @TheMata2111
    @TheMata2111 Před 10 měsíci

    Can someone help me just figure out how to do the first part of the project. I just need a flat mesh that i can draw using splines. no intersections needed

  • @ROK_220
    @ROK_220 Před rokem +1

    Hi, can you help me? how to make a collision mask? that is, when an object enters a collision, it cuts itself out of this collision
    (sorry, I don't know English well, I use a translator)

  • @micflynn1
    @micflynn1 Před rokem

    Sorry but will this work with Unity 2019? I do VRCHAT and am starting to build worlds

  • @jamesc2327
    @jamesc2327 Před 10 měsíci

    so, where can we get this tool you built?

  • @eneseren8332
    @eneseren8332 Před 5 měsíci

    Is these splines only 2D or it works on 3D?

  • @sneffetsd
    @sneffetsd Před rokem

    knowing about road design help, gamers have a misconception that roads are organic or spline based. Actually, road have only 3 types of geometry, lines, circular curves and spirals. you can have two lines with one curve connecting or two lines with two spirals and one curve.

  • @AlekseyLoykuts
    @AlekseyLoykuts Před rokem

    We need collab with Freya on this 😅

  • @Pa3BeDka_Gaming
    @Pa3BeDka_Gaming Před 3 měsíci

    Please tell me how to make transport follow its lane, but at the same time the road will not be drawn as in Cities: Skylines, but will be added as an object in the form of a 1x0.25x1 cube grid system. I've tried almost everything, I don't know what the method is and I won't stop.

  • @RobertMaximVerdes
    @RobertMaximVerdes Před 11 měsíci

    Assembly reference hack is how Neo managed to make the jump. Now I know

  • @parhamrezaee6996
    @parhamrezaee6996 Před rokem

    google wants play billing 5 or newer, can you please make a torurial for that also how to update unity with google billing library 5 or newer? Its the problem of so many people and no one talked about it yet

    • @GameDevGuide
      @GameDevGuide  Před rokem +1

      I don't do mobile development so I don't cover it, sorry.

  • @FurkanKalli
    @FurkanKalli Před rokem

    I don't understand why Unity's own spline solution is worse than other spline packages. 😟 For example, there is the Dreamteck spline package available in the Asset Store, but Unity's own solution is far behind this package.