How To Build Roads Procedurally In Unity with the Splines Package

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 พ.ย. 2024

ความคิดเห็น • 82

  • @realtimberstalker
    @realtimberstalker ปีที่แล้ว +39

    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.

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

  • @CaseyHofland
    @CaseyHofland ปีที่แล้ว +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 ปีที่แล้ว +3

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

    • @aceman0000099
      @aceman0000099 3 หลายเดือนก่อน

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

  • @HangryAnimalsGame
    @HangryAnimalsGame 2 วันที่ผ่านมา

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

  • @matheussantos250
    @matheussantos250 ปีที่แล้ว +3

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

    • @GameDevGuide
      @GameDevGuide  ปีที่แล้ว +1

      Glad to be of assistance!

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

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

  • @GamerChunkZ
    @GamerChunkZ ปีที่แล้ว +1

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

  • @JustDezz
    @JustDezz ปีที่แล้ว

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

  • @nxt_tim
    @nxt_tim ปีที่แล้ว +3

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

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

  • @v0ltdev
    @v0ltdev ปีที่แล้ว +27

    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 ปีที่แล้ว +7

      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?

    • @itsosmx
      @itsosmx ปีที่แล้ว

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

  • @asr59
    @asr59 6 หลายเดือนก่อน

    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

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

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

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

  • @nocturne6320
    @nocturne6320 ปีที่แล้ว +7

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

  • @Briglair
    @Briglair ปีที่แล้ว

    Absolutely amazing! Concise and to the point. Thank you

  • @tokyowarfare6729
    @tokyowarfare6729 7 หลายเดือนก่อน

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

  • @dimasavin6179
    @dimasavin6179 หลายเดือนก่อน +1

    4:42

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

  • @mathew3267
    @mathew3267 2 หลายเดือนก่อน

    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.

  • @skope2055
    @skope2055 6 หลายเดือนก่อน

    Great content! Helped me a lot!)

  • @fx.minecraftgamer2370
    @fx.minecraftgamer2370 ปีที่แล้ว

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

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

  • @birahe1810
    @birahe1810 ปีที่แล้ว

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

  • @adamodimattia
    @adamodimattia 4 หลายเดือนก่อน

    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.

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

  • @RollingHeat
    @RollingHeat ปีที่แล้ว

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

  • @nay2d2
    @nay2d2 ปีที่แล้ว +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 ปีที่แล้ว +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.

  • @AleksandrSknarin
    @AleksandrSknarin 4 หลายเดือนก่อน

    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 ปีที่แล้ว +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

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

  • @luisportilla4109
    @luisportilla4109 ปีที่แล้ว

    where did the sphere come from in the spline sampler script

  • @joeltumelty
    @joeltumelty 11 หลายเดือนก่อน

    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?

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

  • @ShayebGM
    @ShayebGM 2 หลายเดือนก่อน

    What about height map connection spline + terrain

  • @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 10 หลายเดือนก่อน

      Nice

  • @RaviGovender
    @RaviGovender 8 หลายเดือนก่อน

    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!

  • @raikenleo1902
    @raikenleo1902 5 หลายเดือนก่อน

    how do you open the spline in the code editor?

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

  • @vladalx8820
    @vladalx8820 ปีที่แล้ว

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

  • @itsosmx
    @itsosmx ปีที่แล้ว

    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.

  • @jamesc2327
    @jamesc2327 ปีที่แล้ว

    so, where can we get this tool you built?

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

  • @GwydionV
    @GwydionV ปีที่แล้ว +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  ปีที่แล้ว

      Yep the project is available on Patreon 🙂

  • @majort9703
    @majort9703 ปีที่แล้ว +13

    Amazing! but paywalled files :(

  • @micflynn1
    @micflynn1 ปีที่แล้ว

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

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

  • @AlekseyLoykuts
    @AlekseyLoykuts ปีที่แล้ว

    We need collab with Freya on this 😅

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

  • @eneseren8332
    @eneseren8332 8 หลายเดือนก่อน

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

  • @RobertMaximVerdes
    @RobertMaximVerdes ปีที่แล้ว

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

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

  • @Pa3BeDka_Gaming
    @Pa3BeDka_Gaming 6 หลายเดือนก่อน

    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.