HOW TO CLIMB WITH CUSTOM HAND SNAPPING IN UE5 VR | CLIMBING TUTORIAL

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome everyone to climbing tutorial and I'm so excited to do it because I've been sitting a lot and I finally figured out how to do it so you could climb and also you could climb on the surfaces so like if you went halfway on some kind of surface you would snap to it surface on top everything I ask you to turn is just like subscription and comment under this video because I'm putting a lot of the efforts in every video you see here I'm trying to explain in the best way possible I'm it trining on my errors from previous tutorials and I'm trying to fix it so I don't see any reason you should not hit the subscription button right now okay so with no further Ado let's go ahead and jump into tutorials so I'm going to create an empty virtual reality template project and let's call climbing tutorial like this and just hit create okay once we've loaded in the first thing I want to talk with you guys is how do we do custom animations so for the past last week I've been trying to find the best way to show you the animations and how to do custom and what I've recently discovered is that we have here our animation blueprint right and we can right click here and show in folder view so what we can actually do is to create an interface for our animations because if you right click and you'll see here we have something called animation layer interface so animation interface is something that allows us to do custom functionality of our animations if you have a lot of different animations in your game and you want to have different approach to each of them the animation layer interface will be the best choice so let's go ahead and create it and let's call it VR hand like this and go ahead and open it so once you're here we'll see our animation layers so let's just code idle so the purpose of this interface is actually to communicate with other animation blueprints in our game and allow them to have custom animations so therefore we need to go to our inputs and create input like this and in here we can just open the input post inputs and here we'll see different inputs so if we open our AP mannequin XR that's our default animation blueprint that is provided in our VR template we'll see that we have some variables here so for our animation our hand there are four variables responsible those four so to replicate all of our possible movements in our game we're going ahead and we'll create those four variables in our interface right here so let's go ahead and create inputs we're going to click this icon right here and our first input will be our grasp so the amount we have grasped and if you're not familiar with how our VR template works I really suggest you to watch this video on your top right corner I explain every bit of how our VR template works and that will be of help so now let's go ahead and our grasp input will be of type float then we'll have our another input it's going to be for our Alpha point then we'll have thumb up and lastly we'll have our index curl like this then we're going to hit compile and save so now we can just go ahead and close this and let's come back first for our animation blueprint manin XR that's our default one so now we are going to establish our communic ation with our interface so if you click on your class settings right here you will see the implemented interfaces here and once you click on ADD button and search for our VR hands you will see this interface here so let's go ahead and edit and as you have may noticed that our animation layer has appeared here and that's our interface so once we double click on it we'll see that we have some kind of variables right here input Po and output PES and the same happens in our ANM graph so what we can do now is actually to go to our anim graph and we're going to drag our idle animation layer to here and if you click on this vrhe idle you will see you have exposable properties right here we can go ahead and create direct binding between those variables so we're going to bind those four variables to those four variables right here so let's go ahead for our grasp we're going to look for our post Alpha grasp this one for our Alpha point we're going to have current Poe Alpha point for our thumbs up we're going to have our pose Alpha thumb up this one and for our index curl we'll have posst Alpha index curl like this we're going to hit compile and save so once we're here we can go ahead and connect the output of this VR hand idle node to mirror since we are going to mirror the animations and everything we have right here we can select contrl X to cut it from here double click on our layer and insert it right here those variables right here they already represent what we have right here so what would be the use of using those noes we're going to do it one by one so let's go ahead and delete post Alpha grasp and connect this grasp right here let's delete our current post Alpha point and connect Alpha point to here then current POS Alpha thumb up connect to thumb up and index curl we connect to our index curl and the result of this layer blend per bone we connect to result here you can hit compile and save but now we need to make sure that this node is connected too since we have our idle animation right here it will make sense just to delete it and connect this input post to here it's already idle so let's hit compile and save now let's go back to our VR template and let's actually test if we haven't ruined anything that's the essential part so as you can see my fingers still preserve their functionality and everything works wonderful so let's go ahead with our tutorial okay so now I'll explain you how our grabbing will work our grab component which will'll slightly modify later on we'll use custom animation blueprints for our hands our grab component will have the animation layer and this animation layer will be our animation blueprint which will have an interface so basically interface will tell the animation blueprint how we should hold an item so now let's go ahead and create another animation blueprint so let's go ahead and create another animation blueprint that will be specifically for our hand so right click on an empty space animation animation blueprint and we are going to choose it for our SK manin XR and hit create and let's call it ABP climbable Stone like this so all we see here is our output pose the same way we're going to add our interface because we want a custom animation right so let's go ahead to our class settings implemented interfaces and add our VR H and hereit compile double click on our Idol here and we will see our grass Alpha Point thumb up index scroll those are the inputs of our hand so let's go quickly ahead double click on any of those animations you see on your bottom right corner I will click on this one and let's go to skeleton so now we'll have to create an animation that will represent us holding a stone like we're grabbing it right like climbing so I just go quickly through the animation but just for everyone who's watching this doesn't know how to do animations you basically select the bones right here and you manipulate them so it looked like you're holding a stone so I'll just start doing it so this is the animation I've came up with so maybe you can try to do the same but I'll just go with this one since it's just for the sake of tutorial so we can go ahead click on create AET create animation current pose let's save it to our animations and let's call SK man and Exar clim and hit okay now we have saved our animation so going back to our AP climbable Stone animation blueprint we have to get this animation we've just created to our input Poe so let's blend our input post that's whatever post we have right now in our game and we are going to blend it between our climb animation the one we have created right now and our Alpha will be our grasp so the amount we push our button and afterwards we connect our blend to Output pose hit compile and save so now we actually need some object we can climb so I can go ahead to Quick cell Bridge so if you didn't know you have a special marketplace where you can find free assets so you can click on window quicksell bridge and here that's basically where you can download the assets so I'll go ahead to 3D assets and I'll look for a stone so I could climb and let's go ahead and I will choose this one we can go ahead click on download wait until downloads and afterwards you can press add button which will add this asset to your game and the asset is here okay now we have to add our grab component so let's go ahead and look for our grab component so what we're going to do we're going to attach the hand of the motion controller to the stone but we're not going to attach motion controller itself we're just going to attach a mesh so it looked like we're grabbing a stone so let's go ahead and get our is held like this and we're going to check if we're already holding our Stone so in case we do we're going to try release so let's go ahead and get our TR release function here like this and let's move all of the code to the right and if we released we're going to grab it with another hand so again if we're already holding something we're going to release it and grab it with our other hand but in case we're not holding our stone with any of our hands we're just going to go ahead and connect the false pin creating route nodes here to grab right away like this and in case our try release didn't succeed we're going to return just not as held like this so now we need to work in our hand the way it's going to snap to our object so let's go ahead and create a function we'll call it try find hand mesh on controller try find hand mesh on controller so this function will have an input it will be our motion controller that will be the controller we'll be trying to find hand in and it will be of type motion controller component like this hit compile and save so after we have found our motion controller we need to access its mesh right so let's go ahead and get children components so if you go to our VR Pond I'll show you as you can see we have our motion controller left grib and right grip and their children are hand left and hand right that's what we are trying to get from our emotion controller so let's go ahead and create a loop we're going to iterate through every children of our motion controller and try to find hand mesh so for each Loop in this loop we're going to see if our array element is our skeletal mesh cast to skeletal mesh component like this and in case it is it means that that's our mesh so let's go ahead and return it like this and let's call our output as hand mesh so here in case this is true we're getting our hand mesh but in case we have gone through our Loop and we didn't find anything let's just return null so we'll return empty hand mesh like this hit compile and save so now we need to actually create a function that will apply our animation blueprint animation to our hand and attach it to the socket that will be on our Stone smash so let's go ahead and create another function we can call capture hand mesh like this and let's go ahead and create a variable in our grab compter component it's going to be of type Boolean and we're going to call it snap hand so we'll control in our grab component should we snap our hand to the object or no in case we do we need to provide a socket we want to attach our hand MH to so let's go ahead and also create a variable for our socket is going to be of a type name and we're going to have socket name so here we're going to get our motion controller reference like this and we are going to try find hand mesh on controller and as input will have our motion controller reference like here so now after we get our hand mesh from our motion controller we need to check if it is valid that's an essential check because we might not get a mesh and if it's valid let's actually go ahead and promote it to a variable like this it's going to be our hand mesh just for the purpose of beauty we can make reroute notes and afterwards we need to create a sequence so we'll do two things here so first of all we'll apply custom animation if we have it and then we'll snap our hand to the socket so we need to create a VAR able let's call it hand ANM layer so that's going to be our animation blueprint basically was our interface inside that controls the custom animation and here it's going to be of type ANM instance but pay attention it's going to be ANM instance and we're going to choose class reference so we can drag it right here and we need to check if we have provided it in our grab component so let's go ahead and check it's valid class and create a branch like this also a little tip you can create a branch by dragging from here and pressing B on your keyboard that will save you some time and afterwards we need to tell our hand mesh to apply the animation from this head animation layer so let's go ahead drag our hand mesh link anim class layers like this and our class here will be our hand anim layer like this perfect now we have applied the animation for our hand afterwards we need to snap it but before snapping we need to check if our snap hand is true that's the variable we'll set up in our grab component in the object let's connect it right here but before attaching hand we need to store its local transform because if we want to attach hand we need also to think about detaching hand so we need to store the location where our hand was before attaching so let's go ahead get our hand mesh get relative transform like this and we're going to promote it to a variable now let's call it cached hand local transform like this and we're going to connect it to true pin and now all we have to do is attach hand so Hand mesh drag here attach component to component and our parent will be our get attach parent attach this pin to here because we're attaching it to our parent and afterwards we need to do something with socket you remember we have created a socket name here that will be the socket will attach our hands to so here is what I found out that we can have a socket name let's call it hand that will be for our left hand and for our right hand we'll have to call it the same name but add Inver also so it was like an inverse hand for our right hand so if you didn't get it it's okay you'll just see it in the code so what we'll have to do now we'll have to use a special node called format text it's right here and what we'll have to do here so basically this notes is responsible for formatting our text we can do the following code curly braces zero curly braces underscore inverse so if you hover on format text you can see that you can use curly braces to denote formed arguments and if you use zero it means that it will take the socket name and put it here instead of zero and what we're going to do we're going to get held by hand and let's check if it equals for instance to write and we're going to direct from socket name select so let's go ahead and connect this Boolean result to here so in case we have our right hand we will use our socket name underscore inverse so let's go ahead and convert it to string and connect the output from this node to here so let's go ahead and connect the socket name from here to our sucket name and make sure that here your scale rule will be keep world and everything else will be snapped to Target that's the essential part make sure you have it click compile and save now we come back to our Tri grab and let's put our function right after call on grabed since we have grabbed the item successfully we need to capture our hand mesh so this function will not happen all the time this function will only work when we have our snap hand enabled so that's what we are going to do in our Stone blueprint so once we capture our hand we need to able to release our hand so let's go ahead and create another function and we are going to create it release hand mesh like this so once we have applied our animation to our hand we need to remove the animation from our hand once we release we're going to create a sequence we're going to get our hand anim layer we're going to check if it's still valid maybe in some cases it's not going to be valid and we're going to make Branch get our mesh get our hand anim layer and we're going to now unlink anim layer class and hand anim layer connect here and it's going to happen untrue and afterwards we also need to check if we are sniping our hand so Branch here and now once we detaching our hand from our Stone whatever object you're using in your game we need to attach the hand mesh back to our controller so let's go ahead and drag our hand mesh attach component to component it will automatically detach it from this tone and our our parent now will be our motion controller of reference right here and make sure your location rule is keep world like this as you remember we have cached our hand local transform so let's go ahead and get this variable right here and now we're going to directag from our hand mesh set relative transform this one and our new transform will be our cach hand local transform hit compile and save so now we're just attaching our hand mesh back to our motion controller using this position that was before grabbing that's logical and now we need to release our hand mesh in our TR relase function and we are going to do it before call UND dropped right here that's everything for our grab component so let's go back to our VR template and we are going now to make our climbable Stone I will create in my content folder you can have any folder you want but just for the sake of tutorial I can create whenever I want so I'll right click blueprint class actor and I'll code BP climbable Stone so as you remember we've downloaded the SS from our quicksell Bridge so let's go ahead and get it we can drag it from here to our climbable Stone and edit here so here is our Stone so since we want to grab it we'll use our grab component right here since we have our grab component you can see that we have our hand anim layer new variable we have our snap hand and socket name and grab type so for the grab type you'll have to choose custom because we are not taking the stone we're not attaching the stone to our hand we need to attach hand to our Stone so we will use custom logic afterwards we need to make sure that snap hand is set to true because we are snapping now our hand and also you need to choose your hand anim layer that's going to be our ABP climbable Stone and now we have to choose our socket name but we don't have any sockets therefore we're going to click on our static mesh double click on our mesh here and we're going to create sockets we can go ahead to our socket manager add socket and let's call it hand this will be our left hand and let's position it so just not to waste your own time and make it as quick as possible you can go ahead and create the values I have right here like this so This socket basically represents our left hand position on the stone and afterwards we need to create another socket but remember we have a specific naming rule so we'll have hand underscore inverse because that's how we set it up in grab component and also go ahead and copy the location and rotation I have right here it's just to save your time and also the really essential part here is to add the Collision to our Stone because our VR Pawn will not be able to grab the stone later so let's go ahead and click on our collision and here at box simplified Collision like this so that was the Collision of our Stone now we can go back to our Stone and since we've created our socket we can go ahead and put the socket name right here and it's called hand like this and make sure that your stone mesh Collision preset is set to custom and object type is physics body because our grab component reacts only to physics bodies it will not grab any other kind of object type so make sure you have physics body here hit compile and save now it's time to test it so let's get our blueprint so let's get our blueprint into our level and let's actually see if it works and we have done everything correctly if I go back to our stones and I try to grab it with my right hand and as you can see our hand mesh is in our Stone and if I already holding the stone with my right hand I'll try to grab with my left hand right hand detaches and we have our custom animation layer applied okay so now we have the funniest part is actually climbing and also let's go ahead and do some adjustments for our Stone the same way you're going to your mesh and we're going to change some collisions make sure that you ignore the pawn when we will be grabbing our Stones we don't want the pawn to overlap with them so hit compile go back now we're going to overv our pawn and so what we going to do I know you guys usually have some Locomotion in your game setup you can watch any tutorials of other people doing it and what they usually do is that they have a collision capsule movement component we're going to do the same so you can adjust your gaml to whatever you want so let's go ahead to our class settings parent class and let's choose character so what we'll have to do is actually let's go to our event graph and we're going to create another function it's going to be event tick here so this will be triggered every frame so that's where we check should we disable physics or no so let's create a sequence we'll have two functions here so now we need to calculate the velocities we're operating our controllers with so let's go ahead and create a function we're going to call calculate motion controller velocities like this and just for the purpose of this function I will go ahead and create some variables so let's go ahead create a variable let's call it last frame motion controller left position it's going to be of type vector and the same we're doing for right last frame motion controller right position afterwards create one more variable we're going to code motion controller right velocity and the same motion controller left velocity like this and now inside the function we create a sequence first we'll do our motion controller left grip so for our left hand so let's grab our motion controller left grip like this we're going to get World location and we're going to substract motion controller left position and we're going to assign it to motion controller left velocity like this and after we've count our velocity we need also to set our last frame motion controller left position to the value we have right here and the same way we're doing for our right hand so let's go ahead and get our motion controller right grip from here we're getting its World location we're getting its last frame position subtracting it from location getting its velocity and assigning it to the substract result and connect the sequence note to here and afterwards we need to update its position so let's go ahead and update it right here like this and let's create some route nodes to make it look more beautiful just make sure you have everything as I do because it will play a big role in the future okay we can hit compile and save we're done with this function let's go back to our event graph and put this function here so calculate motion controller velocities to here and afterwards we need to create another function and let's code update climbing that's where our calculations of climbing will be based and here we'll need to have a little bit of code so we need to let our vron know that it is holding a climbable object and the only way to do this is actually to create attack for our climbable object and for your future climbable objects don't forget to do this that's important so let's go back to our blueprint climbable Stone click on our grab component and search for tag and make sure that here you will add tag and let's call climb like this hit compile and save again for every climbable object in future please add the TCH to the grab component of your climbable object that's important let's go back to our VI pawn and here we'll do a sequence like this so we're going to get our health component left we're going to check if it's valid and in case it's valid we're going to see if this component it means our grab component has tag and our tag as we've created recently will be climb and we're creating a branch here so in case it has its tag it means that the VR Pond is in climbing mode because it has grabbed the climbing object so let's create a local variable and it will be of a type Boolean and let's call it is climbing and we are going to set it here to true if it's touching a climbable object and we're going to set it false if it's not so last we need to create another local variable so let's go ahead and create the variable it will be of a type vector and we'll call it accumulated climb velocity and here we're going to set it on true and the input to here will be our accumulated climb velocity plus our motion control left velocity like this actually forgot to do one thing is actually to now out our local variables before our sequence so let's go and do it so we'll set our is climbing to false and accumulated climb velocity to zero like this because when we are not climbing we don't need any accumulated climb velocity okay so that's good for our left hand let's go ahead and duplicate it for our right hand we're going to get health component right like this connected here and here and instead of our motion control left velocity we're going to use our right velocity like this those variables stay the same so then we need to create another two pins to our sequence we're going to do more events let's move it more to the right we're going to get our capsule component and add World offset and connect it to the then two node like this so we're adding our world offset based on our accumulated velocity so let's go ahead here get our accumulated climb velocity we're going to multiply by minus one because once we moving our hand to the top and we are climbing the rock we need to move our body to the bottom and the same way if you're moving our hand towards us we need to go to the opposite direction so we're going to multiply by minus one like this and connected to Delta location afterwards and that's the essential part everything will not work if you don't do this we need to get our last frame motion controller left position and accumulated clim Vector we're going to substract them and assign them to last frame motion controller left position to this variable and the same way we have to do with our right position so let's copy those two nodes get them here instead of our left position we're using our right position like this and we're going to assign it to last frame motion controller right position like here okay make sure you have the same if you don't that's going to be an error and afterwards we need to disable the gravity when we climbing and enable when we are not climbing so let's go ahead get our is climbing variable here and create a branch and we're going to connect it to our than three like this so in case we're climbing we need to get our capsule component and set enable gravity to fals like this and when we Are Climbing we need to also set Collision enabled to no Collision because when we climbing we don't want to collide with anything that's how it's going to work because if you Collide it will cause the sturing of capsule component and therefore your camera so I don't want to do this let's connect it here and whye when we are not climbing we need to enable the gravity and we need to set Collision enabled to Collision enabled like this okay let's hit compile and save let's go back to our graph and add this function update climbing to hour than one right here now we have to work a little bit on our capsule component so as you can see now your VR origin is snaps to zero but when we respond our camera will be too high so we need to get to our VR origin and put it minus 90 Z location like this and let's click on our capsule component and let's decrease its capsule radius to really little like this and afterwards let's move our VR origin to the front that's how we're going to be able to climb and not having any problems with our Collision so let's hit compile and Save in our capsule component let's play with Collision so what I prefer doing is actually go to Collision preset change it for custom and ignore camera visibility and 3D Vision hit compile and save so now if I go ahead and try to climb that I'm now able to climb the stones and moreover I can grab the stones with two hands and I will have accumulated movement with my both hands so that's the beauty of this and also I can grab this Stone like this and climb on top uh there is no gravity when I'm climbing but once it release I snap back to the floor I will go ahead and copy the floor crl c contr v move it a little upwards maybe scale it down because it's too big like this and afterwards I'll make one more copy and I'll put it like this so that we could have a little level here and let's make our climbing so okay uh that's what I've came up with I can grab the stones I can go up if I release it I will drop so that's how it works and let's actually climb on the top I will show you how it works and try to get on top so as you can see I am now on top let's do it again so I can go ahead and climb I can grab everything with my two hands I'll have accumulated movement the same way right here and if I push myself on the top I will be spawned on the top okay guys I hope I helped you with your climbing and now everything works perfectly you can climb in your game you can make some cool interactions and I wish you a good day and I'll see you in the next tutorial
Info
Channel: Yaro
Views: 548
Rating: undefined out of 5
Keywords:
Id: VT1Exnott8c
Channel Id: undefined
Length: 29min 35sec (1775 seconds)
Published: Fri Mar 15 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.