Create a Rope using Blueprints in Unreal Engine 5 - UE5 Spline Component Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
learn to create an action game in a real Engine 5 at unfgames.com in this video I will show you how to create a rope like this from scratch and then we will use blueprints to deform it and create several variations so the first thing we need to do is to create a rope mesh and it's going to be very easy just just go to select mode go to modeling and here we will select a cylinder okay by default it comes using these values okay so if I click here you will have a preview of how the mesh looks like that's a little bit too big for me so I will do is like put a radius of six something like that and it's a little bit too tall so I'm gonna put it something like 80. okay so before accepting um I want to make sure if I go to the Wi-Fi mode by pressing altu I want to have some slides here so I can deform the mesh okay so I can put something like eight for example and this will make my mesh to be like a more friendly when I want to deform it okay and just like that were pretty much done so let's click here and click complete okay so now that we have this what we can do is to delete the parts that were not gonna see so we're going here to the poly edit and we're gonna click here and I'm gonna click here and I'm gonna delete them because I'm not really gonna see them okay just click delete accept and that's it now there are a couple of things that I need to do before if I double click here on the static mesh I will have collisions how do I know I can just go to show complex collision and I will have everything of this will be a collision and I don't want that okay so I will go here to complex go here project default and there you go and now I can put something like a box Collision in file one okay there you go much simpler Collision now what we need to do is to add a texture here so I'm going to my bridge here and I want to look for a rope here and I'm going here to my Surface and here you can see you have a bunch of options I already download this one so I will click add and I download the medium quality because I really don't need much resolution for this at least for this example you can download the highest quality view one or the high quality the medium quality should be good more more than enough so let's just click add and there you will have my textures here okay now let's have a look how it looks like I can go here put it here and there you go now we have our rope and it's working great now it looks a little bit flat okay so what we can do is to actually displace the geometry using the height map uh to be honest this can work for me because if I check from distance and FSG to check the game I really won't see any difference but if you really want to go into detail then just let's just add this just in case you want to have more detail we can go here and go to the displays options here there you go this place and you will see that by default I have like a purling noise okay so what I will do is to go here to texture to the map and then here on displacement I will choose this one my mask and I will put it here so basically what I'm looking for if I go to my content browser and I click here if I check the blue Channel you will see that I have a height map here and this is exactly what I want so once I have my height height map I can just select this and I can just put it here and I can just change the channel to use the blue one now uh this kind of works okay but it's a little bit big so I want to change this to something like two for example and you will see that I already have some displacement going on if I want more definition I can put something like pipe for my subdivisions uh but for me like something like three or two should be more than enough like if I press one that's a little bit too little if I press 2 three three should give me this nice silhouette here awesome so now that I have this I click accept and now we have a look let's rename this row I click here on my content browser I can f press f2 and type SM rope there you go so now what we're gonna do is to create a blueprint so that we can use this rope to generate any other kind of variation so to generate the variations of the ropes using the splines we're going to create a blueprint so I'm going here with Ctrl space to check my content browser and I will just right click here and then create blueprint class I'm going to choose an actor because it's something I will put in the map and I don't need any other class for this one and I will just put it BP this line something like that okay you can name it any you can put any name you want let me move this here okay and now what I will do here is to add a component what I'm looking for is a spline component just like this okay and as you can see this blank component has two little dots okay one is here and another one is here okay it's basically like two different points zero and one okay so what we will do is use the construction script because we will use this blueprint to construct the Rope okay so what I will do is to drag this line here okay and I need to know how many spline points I have okay so for example uh if I have 2 here let me draw this a little bit I can have something like this like 0 or 1 and I can move this blind Point here to have something like two and I can have here three and remember that programmers start counting from zero and not from one okay so it's like zero one two and three this is how many spline points we will have okay in order to get the maximum number of spline points what I need to do is to go to my construction script and then go to get number of spline points that's all we need to do the next thing is we're gonna put a loop here so we can look for each explain point and add the mesh so we're gonna go here I'm gonna put a four Loop you don't want the for each Loop that's like for each class for each instance and we're gonna do the four Loop which will only ask me for index so what this will do is my first index will be my number zero just like this the first spline point and the last one will be my last is point point Okay so you know this will give me like the number of spline points so what I need to do is to do a minus one there you go so because we will start counting from zero if I have four spline points it means I have the spline point zero one two and three and I will just connect this to here okay so the next thing we're gonna do is to add the mesh and instead of going here to add a component because there is a spline component or the spline mesh I can put here and put a add spline mesh component and what this will do is essentially go to here and add this spline mesh component now here I can check my static mesh so I can put the Rope here that's the reason I name it is because I can find it easier I can put the Rope here and then the forward axis I don't really need to change it here because I can change it later okay so what I can do is to go here and then to the set forward axis and I can actually grab this return value and set forward access and just like this you will have the forward access what do I mean by this so if we check our mesh here let me go to Chief s 12 have a bigger space so the forward X this is this axis here in our case is the C axis here that is going into this direction okay so this means all my Dimensions will go like from this direction and the next one I will duplicate and I will put something like like this this will be my second one and this will be like my third one and so on so it will use the x d axis if I put the x-axis which is what I had by default it will do something like this every time you duplicate and this is not something you want so what you're gonna do here is go here and put the C value here click save compile and there you go now the last part is that you need to set the start and the end points because as playing mesh component is a mesh that can be deformed so it needs like from 0 to 1. to select which parts of Dimensions were you're gonna extend okay so what I will do here is to put the set start and end there you go so the target will be the self which means this is the actor and we need the start position and an end position so I'm going to grab my spline Point again and I'm gonna put like uh get location at the spline Point okay this will give me the first location of the spine okay which is the zero in the case of the loop it will start from zero and if I go here this will mean give me the zero axis and I will just put it here I can also go here and get the tangent get tangent this line point and just like this you will go here and drag this here to the tangent Okay click save now we just need the end position okay so how do we get the end position well if you check the splines here let me delete this tree so in this case we're starting from zero here and then we're going here and this is one okay then we're going here and this is two so we're going to we already get this position so to get the next one we just only need to add one to get the next one and if I want to go from the next loop from the one to two I just need to add one to get this position okay so we already get the start position and the end position just like this so what I will do is to use go here Ctrl C and Ctrl B I know what I can do is to drag This Plane here to get the positions based on this spline component and then what I will do is to wrap the index here remember this is not always zero it just starts with zero and then the next one will be plus here and then I can just put one here and I can drag this one here there you go now I can just put the end position here and the end time in here click compile and with this you should be good to go now the target should be this one okay uh this one will be the the start and end position of this mesh remember this spline mesh component means that it will deform the mesh okay so let's try it out we can go here to our blueprint spline let's save everything let's put it here and as you can see you already have this line here however we don't see the material and the reason is that default mesh we're using doesn't have the material we only applied inside the word so what we can do is to go here and put the Rope here sorry put the Rope table now you have your rope here and now you can see we have our spline point if you don't see the spline points maybe you'll see something like this it's because you are in game mode okay this game view if you press G by accident you will see it like this it's like oh where is my spine points just press D and you will be able to see it or you can either click here or set the game view to all I know what I can do is to drag one of the splines and as you can see the end point will be deformed and let me remove the snapping for now and also this one okay so now I can deform my mesh and if I want new points I can use alt and click alt and click and I can go to different axes I can rotate a little bit okay I can do something like this and this is a really nice way to basically create ropes for your game you can basically have like a Circle here remember do not deform too much otherwise you will need to add more spline points just by clicking out and click you will be able to rotate the spline and just like this we have some ropes now let's play our game to check the size of the Rope this looks pretty nice all right so now we have our rope so before we wrap it up um let's just try to have more control over our spline point so what we can do in case you have different angles for your meshes we can change this forward axis here directly on the editor so instead of just changing it here let's say it's oh no my mesh is pointing in the X direction oh no it's not this direction unless you change another one instead of changing the blueprint we can just drag here to create a variable and this is the forward access and we will just click here with the eyelashes and you will see that you have the Open Eye here this means it means it's public variable okay so what we can do now is we can click here on our blueprint and you will see that I have my Axis here that I can change all right so the last thing I want to add in case you want Collision normally for this kind of meshes you don't really want to put the Collision but in case you want it you can go here to the spline mesh component and put the set Collision enabled and then you can just go here and then just put the Collision enable and this will use the Collision you have in your static mesh so now I can have some Collision here so for example I can do something like this but now if I play you will see that I won't be able to walk okay which is a little weird so just in case if you want to enable the Collision you can also put it here as a variable promote to variable and this will be like coalition type then click compile and then you will go here and if you don't want the Collision uh sorry let's just put this one public first otherwise you won't see it uh you can just go here and no collision and then you will be able to pass through and that's it now we have a little rope we can use in our games so if you want to have this blueprint I will put a link in the description where you can download this asset [Music] thank you [Music]
Info
Channel: UNF Games
Views: 29,426
Rating: undefined out of 5
Keywords: unfgames, unreal engine beginner tutorial, unreal engine 5 tutorial
Id: OwQVSPxqUhA
Channel Id: undefined
Length: 17min 32sec (1052 seconds)
Published: Fri Oct 28 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.