How to make Splines using Blueprints | Spline Meshes | Unreal Engine 5 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys and welcome to my spline tutorial video so in this tutorial video i'm just going to take you through my final result of a spline spline which i think is very easy to work with and to use and you could also just use the code that is in here to make your own spline out of it and make some adjustments to it but overall i think this is all a spline should have to do and should suffice so over here we already see uh what we can do with the spline this one over here is splined as well but basically in the end you end up with this spline base class and then we have we can just right click the spline base class and make children classes out of it and these children classes we can then preset these values over here so basically we can set the mesh for our spline the section length i will explain what that is and some other settings here as well such as collision so these are all exposed and then you can basically make as much of these spline children as you want depending on how many splines you need but to showcase what this does if you drag one in eventually then you get the spline just like this over here then here on the right you can select the mesh that you want to put in here so i got a pipe over here so for instance pipe mesh too so this is my little mesh here now i can show you the 3d object over here so it's this one so this is my mesh the end here is not filled and then the front here is i also have one that actually does have an end like this and what you can do then is basically select at the end here so select this little white dot here and if you drag it out it will automatically start to spline it so one important thing to know is that when you do this you have to look at the length of your mesh so if we open mine up for instance this one then here in the top left you will see approximate size and it says 117 which means that's the value that we need by the way 117 is the is the length in on the x-axis so if we take a look at the gizmo here in the bottom left you see the x-axis and that's what we use for this spline blueprint so we need to know the length on the x-axis and that's the first one over here so it says 117 which means one meter and 17 centimeters so the first thing you have to do is type that in here so 117 and there you go so now it's the correct size and now it will automatically start to spline when i drag it out like this and if i hold alt i can then start to drag it up like this and i can then start to also drag it out just like this and as you see it will automatically and very neatly start to spline my mesh like this then there is also another option over here that we can enable collision so if we if we set that to true then i can show you what the result of that is so for instance this spline here on the left this one is a spline as well it has collision enabled so you can automatically walk on it like this and it's as easy as selecting your spline and turning the collision here to collision enabled then we can also allow scaling so let's say we want to scale this entire spline up we can just turn on allow scaling and over here with the scaling tool i could then set the skill to two and as you see that entire spline automatically skills up like this so let's return it back to one turn scaling off and the last feature that we have pre-built into this spline is if you select the end point here you will see that there is now a full pipe in here and basically this half pipe if you only want full pipes and none of these half pipe stuff in your blueprint they can turn this little boolean on here must be full length mesh and if you turn that on it will simply cut it off and keep your spline at complete lengths of your spline static mesh and yes you can then switch this out with any other asset so i can put this one on here it will have to end here so whatever your mesh is you can just turn that on i can also put the cubes on here so for instance this green one and there you go so how does this work let's look at the blueprint so inside of the blueprint you will not see anything in the event graph you will see all of these variables here on the left and as you see these variables here are all instance editable that way we can actually easily access them over here once we're in the viewport here and then everything basically happens here in the construction script so this is all that it is to it uh and here you guys go so you can just go ahead and go through this video and pause it or check out our patreon because you can download the asset there as well so basically first we check if we want to allow for scaling if we do want to allow for scaling then over here we basically have some codes so that we can actually scale this object currently this object is oriented on the x-axis so that's why everything here is hooked up to the x value um so yeah we just do the the x value times 100 to set the original section length and that's how we can do the scaling so this code basically allows for us scaling up the spline by doing it times 100 then this code checks if it must be a full length mesh or not which is that feature that i just showcased you if that's not important then we can just have any spline mesh length so for this scenario we basically we get the spline we get the spline length so over here we just pull this in like this we get the length and we divide that length by the section length so this section length is what we typed in so for instance this cube is one meter by one meter so here the section length is a hundred because a hundred on row units means one meter so that's what we fill in here a hundred and over here it says 155 by default but this one overrides that value so basically this has a hundred so yeah spline length divided by a hundred that gives us an amount so let's say right that your spline length is a thousand if you divide that by a section length of 100 that means that you would then get 10 spline sections so basically that's what the last index means so we want to loop from 0 to 10 in this case and that's how much of these spline meshes we want to add so what does this code here do well this code basically adds the actual static mesh so instead of filling it in here in a return value we set the static mesh here and this variable here is exposed as well so that's the variable that you can fill in over here and then here we have to say that we have the forward axis as the x-axis in case that your static mesh is not oriented on the x-axis so you look at the gizmo and check out what it is but for instance on the y-axis then what you would have to do is that you set this axis here to be y and then also be sure to here in the front hook up the y axis here instead of the x axis okay then continuing down the line so here we have two functions then one to get the start position of the spline section and the other one to get the end position of the spline section and that's what we set in this other engine function then set start and end so basically the start position how it works is we get our section length and we do it times the index so let's say we are at index 2 and we do it times our section length of 100 that means we are at 200 units which means we are at 2 meters and then that 2 meters will basically be our start position over here and then the other function that we see here is the end position of this spline section and basically this works the same but then plus one so let's say that we are at that 200 length right we do plus one so now we are 300 so we do that times the section length so then we have now got basically the spline starting at 200 ending at 300 and that's a section again a section from 200 going to 300 and that's where we then set this spline mesh to be and then finally we can say that we want to have collision enabled so yeah that's basically all the code guys um if you want to go copy it just take a look at it right now and make sure you copy all of this stuff or check out our patreon where this is available as well and then if it uh if it must be full length meshes so we do not allow that we have these half mesh lengths here so basically if we do not allow this but if it must be full lengths like this then we have this little piece of code here below that handles that so what's the difference between this code and this code well basically we get the length of the of the spline divided by the section length so let's say the length is again thousand units we divide it by a hundred that means we have ten sections uh if we minus one on that one so basically uh this deletes one of the sections alright well guys i hope this is nice and that you can have some use out of this blueprint and see you guys in our next video bye [Music] [Music] you
Info
Channel: Kekdot
Views: 45,560
Rating: undefined out of 5
Keywords:
Id: oYmfq1GJaMQ
Channel Id: undefined
Length: 9min 26sec (566 seconds)
Published: Thu May 05 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.