How To Make Organic Shapes In Unreal Engine 5 | Splines Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys and welcome back to another unvention 5 tutorial in today's video we'll be going over how to create organic shapes within immersion 5 using spline so this is a spline and spline mesh tutorial in which you can make shapes like this so we're turning a road from this into this you can see this is just a normal road very straight and we're gonna be turning it into this using the exact same mesh so you have it nice and curved so it's a nice bendy road like this it's more of an organic shape and this will work for anything it doesn't just have to be rhodes doesn't have to be like horizontal like this it can be vertical anything that you want but this is what we're going over and creating today so without further ado let me delete this code and i'll show you how i've done it so the first thing we want to do is we want to actually create our spline blueprint so to do that we're going to press ctrl space to open up our content browser right click create a blueprint class and we're going to create an actor naming this one whatever you want so i'm going to name it road spline bp as that makes the most sense for me i'm going to open it up straight away now in here the first thing we want to add is we want to add in a component in the viewport so we're going to press the add button here and we're going to search for spline we don't want the spline mesh we just want the spine under utility and add that in there that's all we need to do in the viewport so we can compile and save that and now go over to the construction script as we're not doing this in the event graph we're doing it in the construction script so every time this blueprint updates is when this is going to be firing off and doing the code we want and so what we want to do in here is we want to get the spline so hold ctrl and drag it in to get out of this we're then going to get number of spline points like so and out of this return value here you'll notice it is an integer so we want to drag out of this and get a minus so we've got subtract there and we're going to do an integer minus an integer with that bottom one being two now the reason we're subtracting two from this is because this is going to remove the end and start points so we're getting the total number of spline points removing the start and the end so removing the beginning and end and this will then return the amount of spline points in between those two as that's ones we want to actually mess about with so i hope that makes sense this value is then going to go into a for loop so drag out this and get a four loop not with break just a for loop like so connecting that into the construction script there however this doesn't want to be in the first index it wants to be in the last index so if we hold ctrl we can drag this down to the last index like so leaving the first index at zero so it's going to go through a loop from zero all the way up to the maximum amount of spline points we have minus two then in the loop body of this what we're going to do is add spline mesh component so we didn't add it in the viewport we're adding it in here instead now with this still selected we're going to do is change some of the options in here so the first one we're going to change is the static mesh now this is going to be the mesh we actually want to use for our spline and for me that is going to be a road so i'm going to change the static mesh to road segment like so is that the one which i'm using and it should automatically put the material in there as well now the next thing which change is the forward axis down here i'm leaving mine as x but you want to change yours to be whatever the forward axis is for you so if we compile and save this we'll minimize it and open up the static mesh we're using so again for me that is road segment here you'll notice that for me the forward is going this way and that is on the x-axis so if we're to look at this you'll see in the bottom left here we've got the x the red going forwards there if it was facing this way you'll notice that is the y like so and obviously if it's going up that would be the z so just change it accordingly to what it is for you again for me it is the x so go back here and that's all we need to change you can obviously change the collision here as well if you wanted to but i'm not going to bother with that at the moment then after this what we're going to do is drag out of the return value of this and we're going to attach component to component like so and the parent of this wants to be this actor essentially so we're going to drag in the default scene root once again holding ctrl to get it connecting that into the parent there so we're connecting the road or the spine mesh into the default scene route so they're now connected and going to move along with each other perfectly like so everything here we can leave the same so make sure it's keep relative and we don't need the socket name then the last thing we want to do is we also want to set the start and end points and location for this mesh so drag out the return value one more time and simply set start and end like so connecting that into the attach component component there that's the x cube before attaching so now we have something which looks a little bit like this so now we need to actually just get the start and end positions and tangents and that's actually very simple so we'll go back to our for loop here and we're going to again get the spline so drag that in and get it out of this we're then going to get location and tangent at spline point simply like so now this what we're going to do is the point index is going to be the index of the for loop there so the spline point we're getting location at is the current spline point which we're looking at via this loop here so i hope this will make sense it's all connecting in your mind now the coordinate space we want to make sure we leave as local and now this location of tangent here is the starting location tangent so we can just connect location and tangent into start of our set start and end positions there like so i'll move this over a slight bit like this and i'm just going to double click these to get some root notes just to keep it nice and organized like this next we want to get the end positions now it's very simple as well once again we're going to i'm just going to copy and paste this to get location and tangent at spline point with the target being spline however this time the point index isn't just the index is going to be the index plus one to get an add and we're going to add one like so then connect that into the index like that once again coordinate space being local location and tangent going into the end position and tangent there like so and that now should be the code all completely and entirely done for us we can compile save and close that and start setting this up in our level so if we press control space once again drag in our road spine bp we now have it here i'm going to rotate it as i want it to go the other way let me turn on my toggle snapping again like so and now what we can do is start creating our road so to do that what we're going to do is get right in select that other kind of white dot we see there now we've got the spline selected if you hold down left alt and drag out you're going to duplicate the spline point to add in another spine point there and you can do that again and keep just holding alt and dragging out to get more slide points then if you were to move it like this you'll notice it's actually rotating so we can have a perfect curve like this and what you can do is also drag these and move these about to change the kind of intensity of the curve and to make it a bit more smoother so if we go back to this one move it you'll notice this is now changing so it looks a little bit better like so and i can move this out again drag it around and do the same thing over and over again as much as i want to get these nice curves that we have here so now we've got a nice curve in the road i'll do the same thing like this obviously you can get a lot more detailed and spend a lot more time on this to make it look a lot better i'm just doing this very quickly just for the purpose of the tutorial to show you how it works again you can make this look a whole lot nicer than what i'm currently doing here for example the one i showed you at the start of the video i spent a lot more time on so it looked a little bit better than what i'm currently doing here but you can see how easy it is to actually just create these curves and loops using spline meshes here like so so we create organic shapes however we want like that so i think that'll be it for this video as we've done everything we want to do we've created organic shapes using splines in unreal engine 5 so we now know how to use splines and spline meshes to create organic shapes like this and again the more detailed you go and the more time you spend on it the better it's going to look so thanks so much for watching this video i hope you enjoyed it and i hope you found it helpful and if you did make sure to like and subscribe down below so thanks for watching and i'll see [Music] you
Info
Channel: Matt Aspland
Views: 28,182
Rating: undefined out of 5
Keywords: ue4, unreal engine 4, unreal engine, tutorial, ue4 tutorial, unreal engine 5 tutorial, how to make a game, how to, blender, ue5, unreal engine 5, road, spline, system, mesh, meshes, splines, spline mesh, curved, curve, dynamic, wall, fence, pipe, example, ue5 spline mesh, mesh spline, spline meshes, along, add, procedurally, procedural, car, ai, npc, path, object, ue5 object follow spline, follow, ue5 spline, how to use, use, make, create, spline path, automatically, automatic, moving an object, along a, roads
Id: 0laDU3h1pEQ
Channel Id: undefined
Length: 8min 35sec (515 seconds)
Published: Tue Apr 26 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.