Directional Ledge Climbing System 2.0 Tutorial on UE5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] all right everyone welcome back to another tutorial this one is going to be about the ledge climbing system and let's go for it here we have some Ledges we can attach to it we can move around from Ledges to Ledges you have options to go forward sorry upwards downwards left and right like I do you also have the option to jump uh so if you hold shift and one of the directional Keys is a you can also jump from one ledge to another this can also work if you have something like this if you want to jump from one place to another you can I'm just move it a little bit before yeah we need some more space like here let's move here and then want I hold shift and a you can also jump to another ledge like this and then you can move around like so so yeah you can move up move down left and right and you can also jump to the right or left the character is also going to automatically choose if he has the option to have the leg contact on the surface which is pretty cool so he's going to automatically do that so I'm going to show you now how it looks like without the traces so I'm going to turn off the traces and let's see how it looks like because I haven't tested while without the the traces appearing so this is how it looks like uh there is some improvement I probably going to do after this tutorial well the hands I'm going to improve the animations as well but the hands they can be also be done with ik so depending on on the ledge on the location of the ledge I'm going to be uh setting the hand with ik so the hand is going to be locked into the ledge and it's going to give it a little bit more realism when we actually do the ledge grab and we're also going to work with high k for actually planting the the food on the surface so the character is going to be actually uh look more realistic when we lock the feet on the surface where he goes for and I need some improvements as well for getting the the character to be on the height on the on the appropriate height as you can see the hands are not really quite there and when you move to the left and right the animations like they do not look really good but that's a matter of changing animations and I'm going to do that for the patre members but this is not a matter of uh fixing the system this is just a matter of locking the the pelv B of the character into one place uh so we can limit the the location of the character from going forward or backwards I want it just send on the same axis but if I do that then I'm going to have to change some other things and I don't know if it's going to work it's just um a suggestion but that's one way of doing it that I could think of uh and I'm going to explain you later how you going how you're going to be able to change the the location where exactly the car is going to be after you press a certain key for example so you can also detach and you also have this other block blocks here I was just testing some things how I was just testing to see how the character would behave on different blocks so here I have blocks death uh I try to place different blocks with different depths uh against the wall so I have made this wall to be transparent so I'm using a material a glass material here so that you can see that you can see better how what's going on behind the scenes when I press the left as you can see the character goes like this if I press upwards just to see how the character would behave on different situations we also have the Tilted ledge uh so here as you can see on the top left corner it says Le surface angle is bad well that means that the surface of the the angle of the surface of the ledge is bad because it's tilted so the character cannot go for it you can also change the code that the character can can actually grab that ledge but I didn't make it possible for this tutorial just for uh just because we could have some bugs when we actually uh detect Ledges like this but you can also change that in the code for the character to be able to detect and be able to actually grab those Ledges that are tiled or inclined like this one uh so here I have height so if I keep going like this the character is going to keep going like that so this is just test for see how the character is going to behave on different situations here I also have depth so if I keep going like this the character is going to be able to trace it and he going to be able to place his hand hopefully on the ledge uh here we have thin beams uh blocks just testing some things inclin beans and there you go that's it so let's go for the tutorial so the first thing you should consider when I have made a doent here because it's easier to follow through so the first thing that you need to notice is that for the traces to be able to detect The Ledges we have to ignore the walls so I've have selected all the walls and after I selected all the walls I'm going to go to search the details panel you need to do this on your scene by the way uh you're going to have to search for collision and here on the responses we're going to ignore the visibility of the trace responses so that we can that the traces cannot Trace against this blocks here the reason why we do not want to trace is because we only want to detect The Ledges that's it right so yeah that's one way of doing it of course there's a lot of other ways of doing this and yeah I'm playing a s on the background so that's just one way of doing it that's the way I did it but but there's a lot of other ways to it so that's the first step it's easier to select the walls because selecting each ledge I think is going to be painful so so object preparation scri to prepare objects to enable them to be detected as Ledges therefore we will select all the walls uh go to Collision settings and ignore the trace responses ignore the trace visibility ignore visibility right so now let's go for the code uh here on the third person character on the event graph I have selected but I have I have made a separate graph only for the ledge system we're going to go through everything step by step right so here we detect The Ledges and start hanging that's the first thing that we should do uh so here when we press e we're going to check if the character is already hanging or not right if not then we run a function just start detecting lges if the calculation match if the calculations match and indicate that the ledge is suitable for hanging we start playing a montage so now let's check the ledge hang action function to understand the types of calculations and traces we use to detect Ledges so here we have the commments of course here we press the E so that we can go to a branch and this building is going to tell us if we are hanging or not in case it's not which is going to be the case then we're going to start hanging uh this is pretty crucial by the way what we have to do this I have this function here called ledge hang action right if the character is not hanging yet then we're going to take action for the ledge H so what happens uh after soon as I press play and I go to ledge and press e this code is going to be executed right and this function is going to be the first one to be executed right so here after that we have the the ledge hang action function so here for the St one we detect ledge and promote the values so to detect The Ledges and check their suitability for hanging based on the slope degree angle as well as to detect the space for like contact we perform a series of checks we first take a look at these checks step by step uh here I have the step one and I have another function which is to detect ledge uh suitability right so here uh for the step one we detect lges and promote the values so let's take a look at this function first so here as you can see we have a lot of steps one we have one two four and what we worried about here is the step one to the third to the third one they're going to be responsible for detecting the suitability for the character to be able to hang on the ledge the reason we have the trace by channel is because we want to detect only the objects that are already visible to that channel if we have this wall and it is ignored on the visibility for the Tracer responses then this capsule Trace is not going to be detected by this channel I think that's the best way I can explain it so for doing the capsule Trace calculation for detecting the nearby objects we have a series of calculations here right so here I use these two variables just because I can I can basically control where the capsule Trace is going to be after we press a certain button for example so don't worry about those numbers don't worry about this float values whatever float value is in here so this is just a simple calculation for placing capsule Trace I get my current actor location I add 80 on the top of it for the start and 80 to the end so I add 80.1 the reason why I add 80.1 is because I don't know how un ranging do this but if you add do one for the start you're going to be able to have the tray should be detectable something like that I don't know if this is makes yeah I don't know if this makes sense but if you add 80.1 you're going to be able to avoid bugs like that so I get the actor up factor and the right Factor so I can basically customize this values later and place the trace wherever I want it to be uh the radius have height blah blah blah so I like to choose the color of the collapse graph based on the trace color uh that way I can better know what's going on on the code and basically find easier which Trace is responsible for what so here the like this first Trace here is just for detecting the objects to detect any object that has Collision excluding the wall of course and so if an object uses Ed then we save the hit result values so I'm going to just enable the the drug type for duration again so that we can see better on the world so as soon as we press e as you can see there is the sphere this green sphere appearing it is actually a capsule is because the radius is to big uh so yeah we have this sphere or capsule as you can say it as you can call it and we promote this variable to true if it hit something then we promote the first race structure because we're going to use this hit structure value later right if it's false then it's going to return false and the function is going to be terminated uh and you're not going to we're not going to be able to keep running all the step two and step three we're not going to be able to execute them because this value is true it's going to return true and and the function is going to terminate here so to show that that the function is going to terminate here simulate this so as soon as I press e as you can see the return it goes to the return node uh it sets the light surface detected as false which is going to cause this variable to be false and it's like this other codes here are not going to be executed because the first one uh is not going to be it's going to be false right so the code gets terminated here return node so now for the step two is very interesting because we're going to be detecting the possible Ledges right so if you go to ledge and press e as you can see we have a small capsule that is red and this one is for detecting the possible edges so here we we actually use the first Trace structure hit result to actually determine where this capsule Trace is going to be and we have the impact point I add a DOT one here just show for it bugs to the end and that's it if the capsu trace hits an object then we save the second Trace structure and we go for the next step which is to detect the ledge ledge's surface angle which is the yellow yellow sphere Trace by Channel this small one as you can see there so here for calculating where the sphere trace for theing The Ledges surface angle is going to be we actually use the second Trace structure So based on where it hits we're going to use the impact point of that we're going to calculate the forward line distance we're going to multiply by five uh so here for the vertical line length I'm going to add this is actually the height uh for the heights veral yeah verical line length yeah I so we do this and I guess that's it so if that's true which in most cases it will be after we go from the second Trace structure we're going to promote that to a variable and now we're going to calculate the surface slope angle in degrees so inside this collapse graph we have some calculations So based on the player Pawn we're going to use that to this function called Gat slope degree angles and this is going to calculate the angles the degree angles of that surface and if the degree angles of that surface surface equals to zero which in this case it is but in this case it's not if both of them are equals to zero which in this case it is so if I do this it's not going to be zero anymore and if I do this it's not going to be zero to the r degree angle right so you have to be flat uh in order for us to be able to actually grab that ledge I don't use the impact point for this I'm going to just I'm just going to the Lo it so here I just connect the impact normal to here and that's just that and based on this condition if the angle is suitable for ledge hanging then we're going to get to true and this is going to print ring seeing that the ledge condition is good in case it's not like thecode is going to terminate here and nothing is going to be executed like as you can see if I do if I go to this ledge here the code is going to be terminated here and none of this is going to be executed so in case the ledge condition is good as it happens when you go here the ledge condition is good we going to execute the first the the step four which is to detect the space for legs contact so I have different animations here if you go to the animation blueprint we're going to go to this later but just going to show you but I just want to show you the animations that I have so we have the ledge hang idle which is this one so the the legs of the characters do not have contacts with the surface so I have different animations for the Hang idle animations so for that we're going to be so for that we're going to just p a capsule Trace which is going to determine if the character has space for the like count so I have made a variable a bullet variable called leg contact so in case if it's true then the character should have his legs in contact with the surface I can show you a pral example as we do it here as we do it here the legs should be able to have in contact as you can see the capsule in this case it's the blue capsule uh if the blue capsule gets in contact with that surface if it hits uh the surface that the character is in uh if it hits that surface that that means that the character should have his legs in contact with it so for calculating the position of the capsule Trace here it is so this is not really important by the way this is just for details and it doesn't matter if it goes to if it goes false or true the light surface detect is going to be true here so we're not going to need to worry about this code anyway so now we come to the part where I have to play The Hang idle animation so if the object being traced passes all the checks until the third step we should be able to advance and start playing the idol hang animation so I have this event here we call that we call this event which is this one and it basically plays a montage and optionally you have the option to choose if you want to limit the character's constraint in one axis so that the character cannot move to any other axis instead of that one so what I mean by that is based on the traces impact the second Trac structure hit result impact to normal is telling that the character should be on that axis in order for it in order for him to be able to effectively move to that Direction it is going to restrict the player axis into into that direction based on the impact Norm of that second Trace I don't know if you get it but I think that's the best way to explain it so I'm just going to read it uh we set the plane constraints constraints to restrict we set the plane constraints to restrict the characters access movement and that's it so based on the second Trace structure we get the impact normal of and we get that into the plane normal so that the character is going to be restricted to the axis where he's moving at right I don't personally use this because this doesn't have much effect but uh this is just another way this is just another method of doing it maybe this is going to be useful in the future as you once you use different methods I don't know display ledge Montage event that's all it does just play just plays the bontage based on the parameters that you choose here right so I have these parameters available for me here and we have the legs contact which is going to decide which idle hang animation we're going to be playing so the leg contact Boolean will decide whether the character should maintain the like contacts with the surface while ledge climbing it will determine specific parameters that enable customized animation montages and options for the ledge climbing action for example here we play different idle animations depending on whether the character's legs will touch the surface or not we also adjust the playback rate and start animation position time frame to ensure smooth animation transitions after that we call an event named as play LGE Montage event which play the Montage of the parameters we've chosen based on our leg contact bullion so as you can see here setting the plane constraints is an optional choice for limiting or restricting the character's access based on the second Trace impact normal so now we're going to move on with the ledge hang action function and after confirming that the ledge surface is in good condition for proper character ledge attachment we call a function named ledge movement mode which is a function that we prepare the character's movement for better controllability and precision when initially attaching to the ledge as well as for smooth movement along the ledge so this function here is just for setting the character to be able to remove is f on the ledge uh because we said the the character to be on the movement mode flying so we need to change some acceleration values max speed and other things as well as for stopping hanging we need to set these values back to its default value so that's how we do it now let's go for the sequence now the other two events are for position of the character on the ledge so let's first take a look at the set ledge act to rotation event so as you can see here on the title we're going to save the actor's current and desired location rotation and we're going to stop the timeline if the actor stops hanging so here we have the set L actor rotation event we firstly set the actor location as the current location we can save the current active rotation of the character well this is necessary because we need to reference it on a timeline which takes and reads the current actor rotation at each frame so actually for us to be able to arrange the rotation of the character in a way that is going to face the ledge as if I were to go into this direction here on this rotation and I would press e the character is going to perfectly rotate in a specific time in a specific time frame in this case is do 13 milliseconds in this case is do in seconds and it is going to rotate that if I want to change if I want to change how long the character rotates let's say for example 1 second so if I want the character to rotate at 1 second character is going to do that and it's probably not the best option so I'm going to live [Music] AT3 and the time is going to be 13 the value most of the time is always one because the reason why is because we're going to we use something called uh is it lur Vector right and it needs the alpha and it needs the alpha so I have made a function called ledge hang position function which you have two options to choose if you want to arrange the rotation or location of the character let's firstly take a look at this function and let's go for the current rotation first uh here based on the first Trace structure I get the impact normal and then I get the rotation from X vector and here I fix the rotation of the character in 180 adding 180 degrees and that goes to the T rotation so now I know which rotation the character needs to be add in order for it face ledge and that's it as simple as that uh if I don't mark this option so yeah uh this is going to get the current actor location as we previously saved it here so we get the current actor location and save it it is distored in this value in this variable uh so we get that variable so this is the current location so this is the current rotation and this is the target rotation so the lur rotate function is going to pick a initial value and then smoothly rotate to the Target rotation right in this slurp Rotator function we have the shortest path and this is going to ensure that the character is going to take the shortest path in order for it to rotate so let's say for example the characters rotated at 180 degrees he doesn't need to turn 360 to actually reach the desired path which is [Music] 90° so so for example if I take this off and disable this uh the character wouldn't be smart to choose what is the the shortest uh rotation degree that the character should take uh in order for it to complete the rotational value the rotation right so if I were come here and then press e the character will rotate like more than 360° in order for each attached in the ledge so if I take this option to be true uh to choose the shortest path uh this function is going to like determine which is the best uh rotational value that the character should take based on the current and Target rotation of values right uh so it doesn't matter which side which rotation the character is facing at is going to always take the shortest path and that's it now I have this value here this variable it's actually the taking the input of whatever is inside of it so here uh I have created inputs on this function uh one of them is rotational rotation Alpha so it is here if you want to call it you can just call it like this rotation Alpha so you can get the result so the out the output result is going to depend on the input result put here right so that's what happens here and this return value is going to be to the new rotation we're going to set the actual rotation uh so that the timeline is going to is going to be doing the job for So based on the spion if you want to arrange the rotation we chose it here we just uh put this option to be on to be true and here in this case for arranging the location we just put this value to be true and that's it and don't forget to also plug in the alpha so that it updates with the right timeline with the right time frame but I think if you do if you do the opposite I think it's going to yeah do something not great now for calculating where exactly the character should position himself on the ledge we firstly save the current actual location as we do here so as we've saved that we're going to choose the lurp Factor different from the lurp Rotator and now we do the calculation for calculating what's going to be the forward location of the character and the height offset uh the reason why we do this separately is because we want to be able to modify where the character should be able to be on the height position and the forward and backward distance so here we have two variables which we're going to be able to modify later I'm going to show you how you're going to be able to modify them later so here on this collapse graph we have the forward offset and we have the calculation for calculating where the character is going to be at based on the first is hit result right uh here we have the impact point so we use that and we use the forward Vector offset for the height offset we do the same but we calculate with the the current scaled capsule size we're going to take that and we're going to get the offset and we're going to get the impact Point Z height of the third Trace uh of the third Trace structure and we're going to calculate that to be the height of the character where the character should be at on the ledge and all this is going to go to the set actual location so if you want to read more about how you can create the timelines you can access this website here I'm going to leave on the description below so now let's go to the direction movement input so here we have it but let's firstly take a look at this Sledge move left here so we're going to comprehend all the other nodes so here we firstly check if the character is holding the left shift after he presses the a key which is one of the directional keys to move the character so if the character is holding shift then we're going to jump and here on the jump collapse graph we have this function which is called ledge movement parameters we basically set the parameters based on our needs so if I want the character to jump left I'm going to place the trace to be detecting where the character intends to go and I have all the settings all the functions and events inside of each collapse graph because I want to basically use different parameters and different animations for each directional key so let's suppose the character is holding shift and he presses a so we're going to be executing this function here let's collaps graph so if you take a look at what we have inside this function we have this uh we just basically promote all these values and they're going to be like these values are going to be used on whatever comes after to be executed in this case the LGE move directions event which in this case is the ledge movement directions event right uh here as you can see we have the ledge move directions event and we prevent the ledge Direction movement button spamming first so this is going to permit the the player to be spamming the button and profile I can show you right now so if the character is like spamming buttons the moving with the car is going to be all weird and messy so we don't want that s going connect it back and compile save perfect now for the project project traces in the direction the character intends to go checking if such place is suitable for ledge hanging now this is also important if we take a look at the ledge detection function it is the same function that we use for detecting the ledge for for making the character to be hanging on the ledge in the first place right so now we use this ledge detection function again to detect and predict where the character is going to be and what is condition of the ledge that the character is going to be before he actually goes into it if that makes sense so we're going to be using our customized parameters as we have set there that's this we're going to be using our customized parameters as if we want to jump left or either right I don't know uh you're going to be able to change the trace Left Right multiplier so in this case is -222 whatever 2 220 it can be uh whatever value that it's needed for the character to be able to jump it's also going to depend on what animation you have for example this one here I can predict how what is the distance that the character is going to be able to reach right so based on the animation you have you're going to be able to modify this value to fit your needs so yeah we're going to choose this parameters and if the ledge surface is detected where the character intends to go uh this condition is going to be true and now we're going to play a direction ledge Montage so this we're going to choose the parameters uh we're going to plug in the ledge Mage to play we going to choose the play rate starting position and you can also make these parameters available if you want inside here as I've done here it's up to you I think it's a a good option if you have different animations that needs Perfection so if I go to this event it just plays the animation Montage with the with the parameters I chose here right and this delay duration until the ledge crab which affects the height we have to be careful with this with changing this uh for the jump one as it takes too long I have to delay itation sh at 1 second dot three if I in case I would like choose should be two for example uh I think this is the jump left yeah so as soon as a jump it is going to take two seconds until the code corrects the the actual location of where uh the Caron is to got so this code like this delay duration is going to determine how long the character should take until uh they kill tell the character where exactly he should be at he actually should be at so if I do it too early let's say for example do two seconds I so this one you know it will be weird [Music] so so that's what is for and going back there we're almost finishing so after this delay we're going to check if the characters are still hanging because maybe the characters maybe the player already had the the detach option should be uh maybe the character is not hanging anymore and this good is going to be executed it's going to be a mess so if you have any other actions that stops the character from jumping to the left on the ledge then you can put it here you could do and buan and let's say if the character is following that could be a good one get is following from the character movement component you can also do that sorry it's to Oro so if the character is falling don't do that something like this so I can you can add as many as you want so just be sure what's what's in your project and what uh the needs that you need for doing that to avoid bug so here is the position character on the ledge so here I have two as in the AL code uh we set the ledge actor rotation which is an event which is this one uh we also have option to set the actor location and I have this one disconnected because I don't really need it I was having some weird like I don't know rotational bugs like this one yeah I don't know it's up to you uh I need to improve this code more this is optional but if I do this it's just going to rotate the character to face whatever the tracing P Point normal tracing pack normal decides but if you want to get the actor rotation it's up to you um so yeah the ACT is just going to rotate based on the direction of the ledge but if you don't do that the actor is going to be just fine it's not going to it's not really necessary uh here we have the set actual location which is going to just ensure that the character is on the ledge so this is just optional for you uh you don't really need to do this just to ensure that the character stays on that ledge and just make sure that the character is on that ledge with the right parameters that we chosen based on the trace results that we get from there all right so let me close everything here there's too much tabs open so now let's move back to the direction of movement input so I was as I've said earlier uh each collapse graph has their own different parameters and here we're going to choose if the character let's see here we are if we are pressing the left control and we move to the left the character is going to move slowly that's just an option that I've chosen is not really necessary but this is just a a demonstration of how things are too much flexible here you can choose whatever uh the side uh so if the character is holding control we can move slow so if it's sure move slow and if the character has leg no legs contact then we're going to decide which one we should take so that's just a if you want to change the anation that's just a matter of changing also the the delay duration the trace all these options here that you find appropriate if you think that the character is not reaching the height that you need you can also just adjust the pelvis location uh but that I don't recommend that because you can also cause some bugs but you can do this by just setting the pelvis and then click on this option to key so that's going to set the actor the pelvis of the the pelvis B of the character to be lower on the animation and it's solutely up to you and you have to be careful with the changes so we're almost done with' explained the character blueprint part but what about stopping the character from hanging out attaching them from the ledge so if you go back to the LGE system on the event graph uh we have this function that I think i' I've did I've done explained earlier but you have the option to choose to toggle the L hang mode to on off so if the character is already hanging and you press the E again to detach the character you just have to call that function and then just make sure that it's it's disabled so it is going to go to false and it is going to execute the stop hanging function here um so it's going up the animation Mage that is currently playing now we're going to set all the movement Behavior back to normal again disabling this uh this is hanging which is pretty important for the animation blueprint menu I'm going to go to that later so it essentially sets the character movement parameters to favor movement behavior of the character on the ledge and so now let's finish up by taking a look at the character animation blueprints right this one and so here I cast so like if you take a look at the event graph uh here I cast the character we set the essential values that's the only values that we need if to check if the character is hanging or uh the character is having legs contact on the surface right so if you go to the animation graph to have a separated State machine the reason for this is that we can freely expand our code our code base to be to have whatever state stes that is necessary to be the state machine of the light system so here I have nothing more than just the main states which grabs the main State poles from this one so we basically transition from main states to ledge idle if the is hanging variable is true and transition back to the main states if the character is not hanging anymore now for the ledge Ido I use the BL poses by boo which is going to basically choose the right animation depending if the like if the character is having the like contact with the surface or not and that's basically it so yeah I hope you enjoy it if you have any questions you can comment Down Below have this document I'm going to pin that on the description below so you can have access to it so yeah I think that's going to be it for the tutorial I hope you enjoyed if you have any questions you can comment down below and I see you in the next one bye-bye [Applause] [Music]
Info
Channel: LocoDev
Views: 1,770
Rating: undefined out of 5
Keywords:
Id: hbPBCa4z2ko
Channel Id: undefined
Length: 44min 39sec (2679 seconds)
Published: Sat Apr 06 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.