How To Build Roads Procedurally In Unity with the Splines Package

Roads are more common in videogames than you might think so in this episode we'll look at how we can use Unity's new spline package to build out a tool that procedurally creates a road mesh along a spline, and ALSO handles intersections at the same time. While we're at it, we might even decorate it to look pretty using URP Decals too!
Get the package for this video on Patreon - / gamedevguide
Unity 2022 LTS - unity.com/releases/lts
Criterion Burnout Retrospective Talk - • Retrospective of Burno...
Spiderman Talk - • Procedurally Crafting ...
GDC Archive Saints Row - www.gdcvault.com/play/565/The...
--------------------------------------------------------------------------------
Want to support the channel?
▶️ Help fund new episodes by joining the Patreon - / gamedevguide
💡 Get One-Month Free of Skillshare Premium - skl.sh/MKR826
Use these links to grab some cool assets from the asset store:
Get the Must Have Assets! - assetstore.unity.com/top-asse...
Free Unity Assets! - assetstore.unity.com/top-asse...
New on the Asset Store! - assetstore.unity.com/top-asse...
Top Paid Asset Store Packages - assetstore.unity.com/top-asse...
Asset Store Partners - assetstore.unity.com/lists/as...
--------------------------------------------------------------------------------
Socials and Other Stuff:
• Subscribe - kzread.info?...
• Join the Discord - / discord
• Twitter - / gamedevguideyt
• Facebook - / gamedevguideyt
• Instagram - / gamedevguideyt

Пікірлер: 73

  • @realtimberstalker
    @realtimberstalker11 ай бұрын

    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.

  • @spidermankey1398
    @spidermankey139811 ай бұрын

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

  • @dreamisover9813
    @dreamisover981311 ай бұрын

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

  • @CaseyHofland
    @CaseyHofland11 ай бұрын

    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

    9 ай бұрын

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

  • @grahamreid876
    @grahamreid87610 ай бұрын

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

  • @v0ltdev
    @v0ltdev11 ай бұрын

    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

  • @matheussantos250
    @matheussantos25011 ай бұрын

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

  • @GameDevGuide

    @GameDevGuide

    11 ай бұрын

    Glad to be of assistance!

  • @Briglair
    @Briglair10 ай бұрын

    Absolutely amazing! Concise and to the point. Thank you

  • @enescagrbayraktutan6329
    @enescagrbayraktutan632911 ай бұрын

    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!

  • @GamerChunkZ
    @GamerChunkZ11 ай бұрын

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

  • @nxt_tim
    @nxt_tim11 ай бұрын

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

  • @TNTCProject
    @TNTCProject10 ай бұрын

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

  • @asr59
    @asr59Ай бұрын

    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

  • @JustDezz
    @JustDezz11 ай бұрын

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

  • @skope2055
    @skope2055Ай бұрын

    Great content! Helped me a lot!)

  • @domkalan
    @domkalan11 ай бұрын

    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.

  • @Samuel-bd1ms
    @Samuel-bd1ms11 ай бұрын

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

  • @shadow_xts
    @shadow_xts10 ай бұрын

    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!

  • @fokeyjo
    @fokeyjo11 ай бұрын

    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).

  • @whateverr12312
    @whateverr123129 ай бұрын

    damn it is so clever, how can I think out like this. One of most valuable tutorial I'v ever seen. The explanation is very clear too. gotta subcribe patreon.

  • @nocturne6320
    @nocturne632011 ай бұрын

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

  • @v0ltdev
    @v0ltdev11 ай бұрын

    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

    11 ай бұрын

    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

    11 ай бұрын

    @@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

    11 ай бұрын

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

  • @v0ltdev

    @v0ltdev

    11 ай бұрын

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

  • @itsosmx

    @itsosmx

    9 ай бұрын

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

  • @fx.minecraftgamer2370
    @fx.minecraftgamer237011 ай бұрын

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

  • @GameDevGuide

    @GameDevGuide

    11 ай бұрын

    Glad it helped!

  • @matthiasallner4610
    @matthiasallner46108 ай бұрын

    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.

  • @RollingHeat
    @RollingHeat7 ай бұрын

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

  • @tokyowarfare6729
    @tokyowarfare6729Ай бұрын

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

  • @zORg_alex
    @zORg_alex11 ай бұрын

    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

    11 ай бұрын

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

  • @zORg_alex

    @zORg_alex

    11 ай бұрын

    @@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

    11 ай бұрын

    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 🥴😆.

  • @RasmusMolck
    @RasmusMolck10 ай бұрын

    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.

  • @IPv6Freely
    @IPv6Freely9 ай бұрын

    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.

  • @krum3155
    @krum315511 ай бұрын

    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.

  • @nowherefool5869
    @nowherefool586911 ай бұрын

    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?

  • @RaviGovender
    @RaviGovender2 ай бұрын

    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!

  • @vladalx8820
    @vladalx882010 ай бұрын

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

  • @birahe1810
    @birahe181010 ай бұрын

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

  • @joeltumelty
    @joeltumelty5 ай бұрын

    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?

  • @luisportilla4109
    @luisportilla41099 ай бұрын

    where did the sphere come from in the spline sampler script

  • @nay2d2
    @nay2d27 ай бұрын

    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.

  • @ROK_220
    @ROK_22011 ай бұрын

    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)

  • @jamesc2327
    @jamesc23277 ай бұрын

    so, where can we get this tool you built?

  • @Sylfa
    @Sylfa11 ай бұрын

    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.

  • @sekunriruisen506
    @sekunriruisen5068 ай бұрын

    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

    8 ай бұрын

    Yep the project is available on Patreon 🙂

  • @TheMata2111
    @TheMata21118 ай бұрын

    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

  • @Pa3BeDka_Gaming
    @Pa3BeDka_Gaming20 күн бұрын

    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.

  • @eneseren8332
    @eneseren83322 ай бұрын

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

  • @micflynn1
    @micflynn110 ай бұрын

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

  • @tomtomkowski7653
    @tomtomkowski765311 ай бұрын

    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

    6 ай бұрын

    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

  • @vivekpattnayak8443
    @vivekpattnayak844311 ай бұрын

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

  • @GameDevGuide

    @GameDevGuide

    11 ай бұрын

    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

    11 ай бұрын

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

  • @sphelelelubanyana1750

    @sphelelelubanyana1750

    4 ай бұрын

    Nice

  • @itsosmx
    @itsosmx9 ай бұрын

    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.

  • @majort9703
    @majort970311 ай бұрын

    Amazing! but paywalled files :(

  • @sneffetsd
    @sneffetsd11 ай бұрын

    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.

  • @RobertMaximVerdes
    @RobertMaximVerdes8 ай бұрын

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

  • @parhamrezaee6996
    @parhamrezaee699611 ай бұрын

    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

    11 ай бұрын

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

  • @AlekseyLoykuts
    @AlekseyLoykuts11 ай бұрын

    We need collab with Freya on this 😅

  • @FurkanKalli
    @FurkanKalli11 ай бұрын

    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.