How To Build Roads Procedurally In Unity with the Splines Package

Поделиться
HTML-код
  • Опубликовано: 7 янв 2025

Комментарии •

  • @realtimberstalker
    @realtimberstalker Год назад +42

    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 Год назад +14

    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 Год назад +3

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

    • @aceman0000099
      @aceman0000099 4 месяца назад

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

  • @spidermankey1398
    @spidermankey1398 Год назад +11

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

  • @v0ltdev
    @v0ltdev Год назад +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

  • @matheussantos250
    @matheussantos250 Год назад +3

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

  • @GamerChunkZ
    @GamerChunkZ Год назад +1

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

  • @v0ltdev
    @v0ltdev Год назад +28

    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 Год назад +8

      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 Год назад +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 Год назад +4

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

    • @v0ltdev
      @v0ltdev Год назад +4

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

    • @thisosama
      @thisosama Год назад

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

  • @asr59
    @asr59 8 месяцев назад

    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

  • @enescagrbayraktutan6329
    @enescagrbayraktutan6329 Год назад +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!

  • @nxt_tim
    @nxt_tim Год назад +3

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

  • @shadow_xts
    @shadow_xts Год назад

    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!

  • @JustDezz
    @JustDezz Год назад

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

  • @grahamreid876
    @grahamreid876 Год назад +1

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

  • @Samuel-bd1ms
    @Samuel-bd1ms Год назад +1

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

  • @TNTCProject
    @TNTCProject Год назад

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

  • @dreamisover9813
    @dreamisover9813 Год назад +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

  • @zORg_alex
    @zORg_alex Год назад +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 Год назад

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

    • @zORg_alex
      @zORg_alex Год назад

      @@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 Год назад

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

  • @domkalan
    @domkalan Год назад +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.

  • @joeltumelty
    @joeltumelty Год назад

    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?

  • @nay2d2
    @nay2d2 Год назад +3

    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.

  • @Briglair
    @Briglair Год назад

    Absolutely amazing! Concise and to the point. Thank you

  • @skope2055
    @skope2055 8 месяцев назад

    Great content! Helped me a lot!)

  • @matthiasallner4610
    @matthiasallner4610 Год назад

    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.

  • @nocturne6320
    @nocturne6320 Год назад +7

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

  • @fx.minecraftgamer2370
    @fx.minecraftgamer2370 Год назад

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

  • @tokyowarfare6729
    @tokyowarfare6729 8 месяцев назад

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

  • @krum3155
    @krum3155 Год назад +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.

  • @HangryAnimalsGame
    @HangryAnimalsGame Месяц назад

    Amazing walk through. Fascinated by this setup and the potential to build with. Utilisation for foliage is crazy good! 🤟🏴󠁧󠁢󠁷󠁬󠁳󠁿

  • @mathew3267
    @mathew3267 3 месяца назад

    Driving on these roads is only going to work with the wheel collider or a raycast where you on not using a collider on the spline. Otherwise your going to get a lot of ghost collisions with the small imperfections where the pieces connect.

  • @Sylfa
    @Sylfa Год назад +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.

  • @luisportilla4109
    @luisportilla4109 Год назад

    where did the sphere come from in the spline sampler script

  • @raikenleo1902
    @raikenleo1902 6 месяцев назад

    how do you open the spline in the code editor?

  • @TheMata2111
    @TheMata2111 Год назад

    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

  • @vivekpattnayak8443
    @vivekpattnayak8443 Год назад +2

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

    • @GameDevGuide
      @GameDevGuide  Год назад +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 Год назад +1

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

    • @sphelelelubanyana1750
      @sphelelelubanyana1750 11 месяцев назад

      Nice

  • @adamodimattia
    @adamodimattia 5 месяцев назад

    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.

  • @AleksandrSknarin
    @AleksandrSknarin 6 месяцев назад +1

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

  • @fokeyjo
    @fokeyjo Год назад

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

  • @nowherefool5869
    @nowherefool5869 Год назад

    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?

  • @dimasavin6179
    @dimasavin6179 2 месяца назад +1

    4:42

  • @RollingHeat
    @RollingHeat Год назад

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

  • @GwydionV
    @GwydionV Год назад +2

    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  Год назад

      Yep the project is available on Patreon 🙂

  • @RasmusMolck
    @RasmusMolck Год назад

    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.

  • @RaviGovender
    @RaviGovender 9 месяцев назад

    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
    @vladalx8820 Год назад

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

  • @jamesc2327
    @jamesc2327 Год назад

    so, where can we get this tool you built?

  • @IPv6Freely
    @IPv6Freely Год назад

    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.

  • @birahe1810
    @birahe1810 Год назад

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

  • @thisosama
    @thisosama Год назад +1

    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.

  • @tomtomkowski7653
    @tomtomkowski7653 Год назад +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 Год назад

      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

  • @micflynn1
    @micflynn1 Год назад

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

  • @eneseren8332
    @eneseren8332 9 месяцев назад

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

  • @ROK_220
    @ROK_220 Год назад +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)

  • @majort9703
    @majort9703 Год назад +14

    Amazing! but paywalled files :(

  • @sneffetsd
    @sneffetsd Год назад

    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.

  • @Pa3BeDka_Gaming
    @Pa3BeDka_Gaming 7 месяцев назад

    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.

  • @parhamrezaee6996
    @parhamrezaee6996 Год назад

    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  Год назад +1

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

  • @FurkanKalli
    @FurkanKalli Год назад

    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.

  • @AlekseyLoykuts
    @AlekseyLoykuts Год назад

    We need collab with Freya on this 😅

  • @RobertMaximVerdes
    @RobertMaximVerdes Год назад

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