Foot IK Tutorial in Unreal Engine 5 with Custom Character - Realistic Foot Placement

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome in this tutorial we will learn how to add a simple food ik system to any of our characters inside unreal engine 5. first we will define the basics of ik then we will show the unreal example of foot ik that comes with the third person template then we will understand it and we will apply it to any of our characters now in order for this to work our character needs a special type of bond an ik bone that maybe not all the characters will have so in order to overcome this obstacle we will also learn how to implement this foot ik without the need of those bones for those characters that does not fit our requirements the only prerequisite for this tutorial is that you must have some previous knowledge of the animation blueprint i have already done a video on the fundamentals of the animation blueprints so if you want to feel more comfortable with it i recommend you check it out and before i forget if you want to support us in any way be sure to check out our store we have a lot of cool stuff like a free blueprints course another to model a castle inside unreal and our marketplace assets that were made with care and effort if you want to learn more you can consider becoming a member of our channel where you will get exclusive tutorials that can take your game development skills to the next level so let's define inverse kinematics we can check wikipedia it says is the mathematical process of calculating the variable joint parameters needed to place the end of a kinematic change we really don't need to know this in a real inverse kinematics are used to allow reactive animation such as food placement or non-planar or non-planar terrain so what does this mean that instead of the bone just following the animation here we'll have the t-bones following the animation we can make changes on the end location in this case i want this end location to be on top so we want our feet to be in this case this foot i want it to be placed here so now i need to do the calculations to know where to put the knee where is the hip it will be very easy because the animation will be in charge of providing that information but the knee here in this animation will be here but now that we have changed the end position of these bones we need to calculate that and that is the inverse kinematic so you can just put it like this if we have this distance and our bone is like this then maybe when we move a little bit further our bone will have this position so doing this calculation is how we will obtain these results and how inverse kinematic work so if you really want to research it there are a lot of information in our case this simple information works for us it's just a way to determine the position of bones whenever we have an end target and how can we accommodate them in a believable way and that's what we're gonna do next for the put ik let's start by creating the project as always here let's click on the game project and select the top no not the top down the third person project blueprints is fine and i'm gonna call it ik bit demo so this project already comes with a character that has the ik setup and we're gonna use the same setup that unreal has gave us it's an easy way to do it but it does have certain requirements so let's update that and dismiss the plugins let's just press play and test that everything is working correctly so there's the ik fit now if we wanted to analyze this we can simply search the character if you don't even know how to search the character well when you press play here in the outliner you will see all the the things that exist in this level in this gray color and anything that is spawned during gameplay will have this yellowish color so this blueprint third person character is the character that we are using here in this demo it comes with the template and well you can see all these other stuff that gets created during the the gameplay of our game so here third person character we can click on edit the third person character and we really don't need it to be running so let's stop the execution here and let me put my hotkeys just in case here we can see what's happening inside the character the input but what we want to check is here in the viewport our character skeletal mesh here is the skeletal mesh and also here will be the animation blueprint will draw that is the blueprint that will drive the animations and also inside it probably is the setup of the ik foot well fit now let's open it here browse the asset here's the animation blueprint for the female character and for the male character we will select the female for now and it says here this is a child animation blueprint from the male character so then let's open the parent the parent can can be found easily here if you don't have it in your content drawer then you will have it here parent class animation blueprint manikin search it or you can open it directly with this so here is the animation graph and the event graph of this character we have done already a beginner's tutorial on the animation blueprint but you will find here that it gets a little bit more complicated especially this animation graph we not only have a one state machine of locomotion we also have main state slots and here we have the different states that you can use now this control rig node is the one that is is doing the ik so we can double click it and we will open the control rig asset that is driving that ik now if you want to delve deeper on how it is working then you can do it right here you can start reading this code is almost the same as blueprints with well some differences in the pins and in the inputs these are just variables that we have added before if you have not used blueprints yet we also have a tutorial on that a beginner's tutorial will we where we explain a lot of the editor functions and all the most common nodes that are used during the development in this case if you don't really know blueprints well it is similar so it's really not a requirement for adding an ik fit in our case because we're not trying right now to explain how this is working at at large is just where is my my character for each fit we are doing a trace here a line trace from here to here to see if this feed should be colliding with the normal ground or if we are in this kind of situation we just we're doing the trace here but in this case the collision is not here but it's instead in this ramp so we are obtaining this location and making the bone of this fit match that location and the ik part is just solving well let me change the color if my foot is right here and my pelvis is right here where should i put the knee so that's the part that is being solved by the ik and we can see here we are doing an ik trace interpolating the sea offsets use the lowest food offset to prevent overextend tension of the pelvis and then we add those transformations here and move the bones up or down here we use the full body ik to solve it as a whole not just a leg so that way when we play the game and we encounter these scenarios we are also affecting the way our pelvis is moving okay so that's a little bit of the theory not the specifics of it but in this case we only wanted to work with our character and here we will find that i need a bone called ik food l ik food r depending on how you're rigging and skinning your characters well just reading really depending on how you have rigged them you will have this ik bone if you are buying a character from the marketplace be sure that this bone exists so what i'm gonna do is import the character one of our characters from the marketplace and we will add this same setup to its control rig and well we will need to create a controller asset and then start copying and pasting so let's add a character that will be able to use this approach of ik fit to know which character can use it you need to know that these bones exist let me check here in the skeleton here you should have ik food ik hand but we these are the two that we need in this case this character was created with the script of rigify well not regified ufi that is a plugin for blender made by one of the community in unreal so let's check this skeleton and it will we check the skeleton then we have those ik bones which we need so let's just migrate this character right click on the folder migrate it everything here is okay let's okay and search for our unreal project that i call ik fit demo content and select oh let's just uh that i the content select folder some content cannot be copied let's see what did not copy correctly uh build that doesn't matter okay so let's go back to this project we should have our cute girl character here let's open it and here we have it okay so we could where's our character now if i'm searching for a specific blueprint i can search it like this blueprint third person character and i'm just gonna show it in folder view so i know where it is i'm just gonna create a child blueprint i'm gonna call it my character and set it up in this game mode my character right now should be exactly the same but if in my character i change the skeletal mesh to the cute girl and also change the animation blueprint that should come with a cute girl facelink this is not it i don't remember how i call it so let's go to animations here retarget we're gonna filter here by blueprint or well animation blueprint and here we have it third person let's just select that we can press play and it is working now it's using right now retargeted poses of the third person character it's what it was created before the release of unreal five so it has that manly pose but what we want to do is the ik fit so let's create that asset now so we need the control rig asset let's search for our skeletal mesh and let's remove this filter by clicking on it or just right click it removing it and here we have the skeletal mesh we will right click create and control rig we will call it control rig utker ik fit and we will open it let me save everything so i don't lose any progress i'm gonna close this this and also this right so what i need to do is use this control rig code in order for this other character to have the same behavior okay right now it's really not that simple as just selecting all these and copy and pasting because the times i have done that and the variables did not exist then it gave me some errors and ultimately crashed my computer so we do want to know that we are using the forward solve so here if you have it in instead whoops in backward solve put it in forward solve now we need the variables that exists here we have first one function and second all these variables i know i said this first but let's begin by adding the variables we have five floats and one boolean so let's create that float five of them and the last one a boolean let's copy and paste names and you can switch between tabs with ctrl tab and i'm renaming this by using the hotkey f2 and i'm going to pause the by the video because it's just copying and pasting names or maybe it's better if you see it it can be a little time consuming but it is necessary in in order to avoid some crashes in blueprints it it's easier if some variable doesn't exist it creates some gray variable and you can right click it and just um promote it to a variable and then it exists and it is easier but here we really need to do it that this way or at least in this in the release version of the engine now we need a function i just clicked here added a function it i want to call it exactly the same put trace double click it to open it here and double click it also here to open i'll copy and paste this here it is now let's let's check what is asking me item ik football here i don't have an item so let's just put it like this all right also it's not like oh it is like the blueprints that you can drop it on top and it will create this item i really need to call it exactly the same so let's here select everything here and yes copy the name for the output we use this hit location and it is called hit location but here is not called hit location it's called offset as a return value a vector return value and we need to check that all these notes are exactly the same which they aren't so let's check it global space initial this seems like it was copied well bone bone root root okay so far so good we solved this need to be connected so let's connect it oh sometimes you have this error when you're copying and pasted pasting notes in in control rig don't worry you can just it's because the the editor thinks they're already connected so we're just going to disconnect it you can right click and disconnect or it's easier if you just oh i didn't get the the option to disconnect so that's why i'm using another way here this result can connect it to start and this other result to end now you can disconnect it you can break the link but i'm just gonna connect it the right way but this now they are connected if you press play sometimes it crashes on me if you press play and you don't fix this sometimes it crashes but this way don't at least it hasn't crashed on me yet the heat location is already connected here we added added it so so far so good these have these icons because there being a debug edit visual debug later we can turn that debug on if you need but we have this function working or well at least not working yet but properly connected and i'm gonna put it like this right so let's compile it save it so far so good we have not copy and pasted this part that is the most important part but we have all that we need before we do that so now we can go back to the regraph select everything i believe you can even select the these forward solve but i don't like doing it copy paste it here be sure to leave a good amount of space here and this action requires a function to be localized check the functions you want to create put trace should be the same so yeah let's put okay and it created a foot trace for me hmm that didn't happen before in the in the preview version well i'm just not going to connect it just yet let's just check if something is wrong or not so first let's check values should do ik race right here is false but it is instance editable so let's make it instance i did editable these offsets should be just zero yeah so that this is fine for now now we we compare branch right now it's okay but bone ik foot i can put l here i should check for the same ik food l and it seems that it didn't catch it immediately because the ik was in lower case so we can just search it very easily right this part is okay right now i'm using a food trace that is not the one that i need oh but it seems that it copied perfectly this didn't happen before when i tried to use it so let's just use it let's just remove this i don't want to hit compile just yet because i have a lot of errors but for now i'm gonna leave it like this this has the correct names offsets sets the variables interpolations let's let's check if this is correct scale seems like it's the same values we have the same variables if condition yeah so far so good here interpolation have some errors it's because of the naming convention my ik is in lower cases so let's just change it to the ik that works and here bone pelvis should be exactly the same so so far so good the last part we just need to fix the ik ik again but r and the food should have the same name at least in this character or in most marketplace assets it should have the same name so well now we can connect it and now we can see if it is working let's connect this compile it save it so far so good this i'm gonna change to food phrase without the one compile it save it and in order to use it we need to remember that the animation blueprint here we have a control rig alpha should do ik trace we need to add this to the animation blueprint of our character so let's search it open it it's not independent graph is in the anim graph it you can see it's very very simple compared to the other one so let's here one for read the control rig the class that i want to use just like in this case not this case this case here should be ctrl mannequin basic foot ik here is whoops select the one that cute girl ik fit let's compile and it's it's not showing me my my variable so here let's check should do use pin or use curve should be input here i have an input so let's add that input here it is now we can put it true because in my other animation oh we're using this is filing falling we should not do ik tracing if we are falling so this makes sense let's copy oh this already have a easy narrow so we should do the ik trace if it's not in the air it's the same principle and should be being set up the same this variable is being set up in the event graph here is falling is in there it's the same thing right let me just make sure of that it's falling yeah it's exactly the same let's compile it save it and now let's see if it is working let's press play and it's it is working but now we need to do some some work in order for it to walk around otherwise we will be using the ik on everywhere except when we are falling and evening we're following i believe is he's doing the ik trace right we can disable that should do the ik trace false and it's not listening to me now something like this there it is so now we just need to fix that part of the ik trace phrasing and we should be good to go in order to fix it we first need to understand what's the problem if we check out the animations of the mannequins here we will find the running animation we shouldn't worry too much about this notifies but i do want to select here in the escalation tree the ik put and i see that the movement is being driven by that ik foot or at least it is moving with the foot let me pause it and we can see it is moving we can find also the the foot bone and it also moves around but if we open the animation of our character which we retarget well this character comes with retargeted animations as a test we see here's the run if we press here in the skeleton tree for the ik food it's not moving around if we search for the put joint that one it is moving but it's not moving my ik so we can in order to test that it is working correctly we can try to modify the control rig but instead because i really don't like those animations we're going to retarget the animations of the female mannequin in this case queen these are the animations and we should be able to retarget all the assets to do that here in riggs we will need a retargeter that well unreal already gave us one so we don't need to waste much too much time creating it this retargeted needs a source ik rig asset which it's already created for us and also a target ik rig now let's create one for our character let's go to the skeletal mesh right click it and create and it's not here so well we can also right click animation ik rig i'll select the cute girl i'm gonna call it ik youth card open it here i have all the bones that i need but let's see the ik rig of our characters again mannequin is here so let's put it here and here we have a full body solver but also here in ik retargeting we have some some values so those values we need to match and there are a lot now that i see them so i'm gonna do a few of them here i can retargeting and show you how you can add it easily now let's go to the cute girl and we need a chain for the spine if i could i would hide the face bones but let's just um skip that so here in my ik we need to set up a retarget route let's choose the pelvis right click set retarget route now we need here a spine spying chain from the spine 1 to spine 5 so spine this case to spine 3 right click it and new retarget chain this is from spine1 and it has the same name or it doesn't have the same name so let's put the same name spine now we have the left arm and we can see how the these spines oh well these chains work this case left arm from the upper arm to the hand so i'll select upper arm to the hand does this have a clavicle it sure yeah it does have one but it is not being taken in account so we can see the start bone and the end bone and then we can try to match it to our character and this one is called left arm now you can see that this can get a little bit tedious but you really need to make sure that everything is matching here ik gold we need to select an ik goal for this and in this case is handle gold which is here we can create that by selecting the chain going to hang l and right click it new ik gold we have body mover the invite a set transform all solver let's check what we are using here full body ik effector goal name strength alpha and this is the goal goal additive and here i see that it is being using this full body ik so if i try to move it around yeah it should influence all the body so i'm not gonna pay too much attention to it just yet or well maybe i should show it now because i'm gonna then pause the video and do everything everything that we need so to create the solver in our character we'll add new solver full body ak root bone it asks us and we should match retarget root pelvis pelvis settings full body ak this is the root bone so i'm gonna open the ak select that right click the pelvis and set root bone on selected solver now we are missing goals let's go to my hand l did i miss it here it is no han r and l right click we can set up a new goal here we go settings for full body ik so i believe the hand r also have it yes then the foot are foot l gold so let's search for the hand new ik gold it is i'm able to select this gold gold without choosing which one i want because i have this solver selected put put r now we have the the goals set up and now here in the left arm i can select the ik goal hand that's hand r and l go and now it's exactly the same as this chain now for the pinky there's also a chain left ring so every single single chain that you will find here you need to replicate there are also twists here and let me try to select this twist here is just from the lower arm twist fro is start from here and it ends there so it's really easy to to add these ones we have these two twists the same for all the other twists and if our character does not have this twist or does not have some kind of bone that we are missing then we don't need to add that chain okay so for now oh here we have a left clavicle right clavicle put okay for now we just need to copy and paste well not copy and paste just replicate what we have here in this ik rig to the one that is our character so i'm gonna do that and i'll show you the result so that took a while but i now have almost all these chains here in my character i made sure that the names are the same and also the start bones and end bones are the same so now that we have the ik working we can now proceed with retargeting we will go back to the retargeter which if you don't have it open you will find it here in characters mannequins rigs rtg retargeter and here it is now we can change this target ik rig to the cute girl one and start previewing animations for example running and we can also see working polling idle and we just need to change a little bit of the settings in order for this to work correctly let's start with the running here let's make sure that in chain mapping this has been mapped correctly so we can automap in order to refresh if we change another another chain or create one that we are missing for this part for example lower oh it's okay for now yeah everything is being changed correctly and the source root should be working be working well as as well well yeah we have selected this pelvis and in both eye case it should be set up as the working retarget route and it seems like i didn't so i'm gonna set the root bone sorry target root here that's where i i thought we we did this at this start but anyhow it now it is now selected like that we'll save again and just in case i'm gonna select the cute girl again autumn up the chains so source would pelvis should be fine let's see if this is working now yeah so it is working i'm getting the animation and it's not weird well it's a little bit weird not gonna lie but let let me see if i can change the the the actor here i'm gonna go here in the ik mannequin and in the preview i'm gonna select the queen escalator mesh and now in the retargeter has not updated so let's close it let's open it and now we have the queen maniki which it seems that it's using the same animations and now we can see that it is working semi-correctly when working with the retargeting well well with the retargeter we have some options for example these retarget faces we can retarget the ik we can decide not to retarget the ik retarget the fk we can also decide to not retarget the fk if i choose the ak in this case then we can see what the aik is doing and the fk is also doing if i didn't retarget the root then i would have something like this so it's a combination of both to get the best results and it really depends on the animations for example here the arm is not looking too too good so by retargeting the ik we can fix it a little bit yep so now let's see if my animations can be retargeted let's save this for now and let's pause this and before continuing we could cover the topic of retargeting more in depth but in case for example there are some animations here that don't look too well for example maybe i i want to change this pose here or maybe the arms are not incorrectly for now it's really not that noticeable but if we want almost or well almost perfect is never perfect is never possible almost perfect really time consuming so if we wanted a better retarget we can check the pose let's edit the pose and here in the target actor offset we can move it around or just put it in zero and we will see that the hands are not a perfect match so we can try to move the legs the hands to match it a little bit better we can also scale scale it a little bit in order to match better but for now let's just leave it like it is because it is giving me a good enough result now we could retarget like oh i want all these animations and let's do that for now i only wanted to change the animations of the locomotion with it which is this idle which is this run and this work the other way the other ones for now i don't care so we can select this export the selected animations good girl animations for now could retarget it and now we have them let's open the animation blueprint of this character and i'm gonna replace either one which is a blend space and i'm gonna replace it by the ones that have been retargeted hopefully if i open these animations the ik also was retargeted but it seems it wasn't retargeted and that's going to be a problem so we need to tweak a little bit of our retargeted retargeter if we want to make this ik move so what i'm gonna do here in the chain mapping i'm gonna search for my foot no not the foot root the left foot and the right foot and here in the translation mode i'm going to select globally scaled and if that gives me not good results we can check if the absolute works for us usually you want to use absolute if you are retargeting the root motion but for now we really don't need that yet root yeah here we go we could add some root motion in the abs but globally scale should be good enough for us perfect let's save this and let's retarget again and i don't want to where is it now here's the retargeter i don't don't want to overwrite the animations that we already have here so i'm just gonna put them here in the content folder for now let's see the run should be opened by now here it is and now the ik foot is moving which is what i needed let's open our blend space here and change the [Music] the animations so here it's going to be the idle one the run one will be here and the oh and in we can snap this by pressing shift and holding it so let me do that when i overwrite this or yeah we can also just delete this and run shift slot being hold and walk forward forward class here so now we can test this and the ik foot is moving correctly let's go to the third person let's press play we are now using the animations of the female mannequin that it seems to be the same ones as the male manikin we have the movement and also we have the ik put working you will see a little bit of clipping because in this case this character is using the some platforms but it does do a good job in most situations if we needed to tweak this a little bit we can add a little bit more height to the calculations in the control rig now while testing this you will see that whenever we are running and it will be working fine but when we jump it give us this because it's using the old animations we can retarget them retarget this and well adapt it to our own character or we can retarget the whole animation blueprint of our manic this case we have the animation blueprint of queen and we also have the animation blueprint of money we have to take in consideration that this is a child blueprint so it will be using the parent as a guide let's try i i really wanted to test this the animation blueprint from queen i'm gonna right click it with target animation acid duplicate our retarget animation blueprint the retargeter will be the one that we were using this one this is perfect the folder i'm gonna create one cute girl animations and i'm gonna call it new folder unreal engine 5 animations like that and let's press retarget seems to be complete blend spaces animations and we have these two i'm gonna select this one and i'm gonna open my character the third person character i'm pressing ctrl b to open asset quickly and it was bp dash lower dash my character double click it that will open it open full blueprint editor gonna select the mesh and here i'm gonna select the animation blueprint is not this one cute girl animations unreal five and oops is this one queen with if we see that it works then we later can change it a little bit for now let's save it third person let's see if we jump it is working correctly and it is it is working fine the landing works fine seems pretty good don't like it that much that the big head tends to tilt forward maybe too much make makes the character crouch a little bit but it is work so we successfully retarget the animation blueprint but we see that there there is still some tweaking that can be done i don't want to leave you hanging and especially when we can solve this right now so let's do it i'll find my animation blueprint and let me open my character because now i'm using a different animation is this my character nope it's my character here it is and this character is now using the retargeted animation class so let's open it and also we need to fix a little thing here let's remember that the retargeting has retargeted this blueprint as a child blueprint and we need to open the parent one and i have this error because this control rig node is using my control rig of the mannequin so we need to change this to the cute girl ik feed or whatever the name your control rig asset was now we're using the correct control rig but still the feet are overlapping the ground so we can tweak this inside the control rig let's double click it and here it is talking about offsets and here it is talking about traces the food trace here we can open the local function and if this is the hit location i just need my feet to be a little bit higher so i'm gonna add vector open this and i only want to modify this c value for example if i put 5 here and save it and play then now my character is kind of flying but at least is not overlapping now in this case the feet when we do the ik trace it's still overlapping and it seems i'm crashing well i didn't crash but it did scare me a little so again as i was saying i managed to get up my get my feet out of the ground but when it it hits um at a volume a collision volume then we are still overlapping and this doesn't look too good now that heat can be fixed here when we are talking about the interpolations of the movement we just need to crank it up a little bit so here we can again add and i'm just gonna going to do it for the left foot and for example let's put 10 here now my left left foot is a little bit affected but is a lot more affected when we do this collision now the values will depend on your on your character but the way i found values that will work for me and did this crash come on nice i found the values that work for me by hearing the food trace just putting zero and here just leaving it like this adding some value this is too much then it's too much so just divide it five five when it it gets too low right now i'm still overlapping a little bit here but now when i do this it's getting a better result so i just need to bump it a little bit this value works for me but to bump it a little bit then i can go to the food trace again and here at one or two let's try with two two i believe is too much because now i'm a little bit floating i'm tippy-toeing so let's try one now seems like it's in the ground and when i do this ik part then for me it's perfect i mean there's a little bit of overlapping just a little bit but is really acceptable so for now i would consider i will consider this character as done and the ik as working correct pretty nice so we have this character working correctly with the ik but what would happen if we didn't have those ik bones for example like in this character our anime girl cleric this character does not possess those bones well it was created a long time ago ago and we were using the animation and rigging tools from unreal and there was really not that much documentation how to use it so we probably missed a setting to import those ik bones so if we could re rig it again then we could get those ik bones but there's no way i can do that for this video so what what approach could i take in order to make this character have some type of ik fit let's first change our character our game mode and select our cleric let's press play and we should have the tariq working this character right now does not have any type of ik right so let's see what's happening inside and now before that we need to see the solution first right how can could we possibly make it well we already learned half of that the solution here if we see the content examples that i should have here in the here in maps ik rig you will find this little example about additive ik if i press play from here shows exactly what i need a little bit of ik that can work with my current animations so let's check it out skill little mesh animation blueprint idt 5k let's check that open it we have the animation of the spider work we have an ik rig component and we have some goals here some positions that we can use to manipulate this offset right so let's double click this rig well here double click this part and we can see the goals we can see the body software solver full body ik and if we check the goals and we move them around we see that everything is moving correctly we already have done this setup before with the full body ik so it's just a matter of creating it and then allowing these goals to be accessed by our animation blueprint like this so we will see here some goals manual input we can't here at the offset needed for each leg and that's what we're gonna do now we're gonna create the ik rig for our character that does not possess the ik bones and then we're gonna expose some variables here to set the map in the animation blueprint so let's start with this to start with this other way of doing the ik fit what we're gonna do is create the ik rig for this character you just need to find a place where to put it right click animation ik rig and select this skeletal mesh that you're gonna use call it ik rig and the name of your character open it up and we're gonna add some solver to allow us to make these ik changes so we need a full body ik we could also use a body mover and alien by k but a full body ak will also work fine missing root bone and well later we can use this not later in this video later in development you can use this to move the arms also so full body aka pelvis will be the root on the selector solver we are missing the goals the goals are the hands and we can use ctrl n to create goals very quickly right so the other hand is being used for full body it's excellent the food and the other food there it is we have our goals which whenever i move them they are affecting my skeleton and in my case i need my feet to move around so i'm going to try to select this part and we will see that yes my feet are moving around but it's not exactly pretty we can fix this movement by setting up some properties of the bones for example i really don't want my hip to do that motion so i'm gonna select the hip the pelvis right click it add settings to selected bone and be sure to have to click the full body ik because will be settings for exactly that solver setting full body okay so excellent i'm gonna click it and here we have rotation stiffness and position stiffness in this case and i'm gonna make it rotate a lot we really don't want this movement we could select this pelvic settings stiffness rotation and put it to one if i put it to one no more rotation will happen on this bone but that won't be really realistic so let's just set it 0.8 something the same with position i really don't want my leg to have so much influence on my pelvis so let me select the pelvis again and the position stiffness also should change either to one or a little bit less zero point light but maybe could be a good value this will let me move the leg around and having a rotation that it's a lot more believable now if i go to the front this rotation is really not believable so we need to set up a preferred angle for this bone this bone is the calf in this case the right cuff i'm gonna right click it at settings to select that bone select here the settings we also have this rotation stiffness and everything like that but we really don't need this because we do want it to rotate we do want to for it to move around so here we can set up a preferred angle this will change to true and we can play around and see what should be that preferred angle and maybe this like 80 could be a fine value if i don't agree with it maybe i want to be more just be sure that you are selecting a good angle otherwise you will break the character's leg so maybe something like 90 good work and just check if it is working correctly in most of the cases yeah and it seems acceptable enough at least for me good pretty good so now we also need to set this one up otherwise we have something like this let's go to the other cuff settings settings for the cuff preferred angles and change it to an angle maybe 100 for both and this is something that you can tweak if you see something wrong you can tweak it later and we can reset the pose yeah so it is working very well here you could also tweak the shoulders to not move around that much the club should be the upper arm you can add settings again maybe the position stiffness could could be a little more a little bit more the rotation the rotation i believe is fine just the stiffness so it doesn't look too weird where's the other upper arm at settings for this uh position was 0.8 and there we have it a little bit better we as i said we can tweak this as you would like let's just reset it for now but here in this gold the food goals be sure to click on expose position this one and in this one now let's save it let's go to our animation blueprint of the character and this is not the animation blueprint of my character if i do remember we we retarget all this stuff animations where did i put this well i can open my character uh believe it's called my character and no this is not my character the blueprint of my character is this one and well oh i'm i'm confusing things the the animation blueprint we retarget was the other character here is it really is this one so let's open it here this is not default oh let's open the animation graph this load defaults make us the makes the animation montages available for us so that's why this slot is here so here i'm gonna add ik rig i'm gonna select my ik rig cleric and here we have the put l gold position just gonna promote it to a variable call it put l offset and i'm gonna oops duplicate this ctrl d and going to call it put r offset and connect it here right now if we compile and save we can change these values here in the anim preview edit and here food offset we can see that the leg can go up or down depending on where they are now i do have a little problem here maybe the preferred angle should help me solve this in a better way so it's it's just a matter of seeing which animation animations my character is using and then we can we can tweak the values of the preferred angles let's let's tweak it right now maybe a little bit less because this is something like this and where is my calf right let's try it with 50 in both cases let's save it let's go to my animation blueprint let's compile it and let's see if it's a little bit better i mean we won't be able to do anything if this happens but at least is just a little bit of rotation now and not much of it nice so we have these values and now we need to get them from somewhere so that's what we're gonna do next set up these values doing the line traces that the control rig did for us in the last well in the first version of this ik bit but we're gonna have to do it a little bit different so let's fill these values that right now it are at zero to do this let's compile they save we will go to the event graph we don't really need this other stuff and in the event graph we need to trace do align trace do a capsule test whatever we need to do to get the collision values and also we need to check that we really don't need the ik fit to move around if we are not in the ground right so we will use this is in our right so let me move this stuff around and after everything is set up here and i'm gonna put it like this after everything is set up i'm gonna do a sequence and this will execute later after running all this stuff so what are we gonna do here we're gonna ask if we are in air you can see that here we're just getting that is falling it's just that in a real form this was usually called inner well you you created a variable called easiner but now it's just directly is falling so here i have easiner this is how you get it and now let's ask if it is not inner and this wasn't the note that i needed it's better to just put this one not boolean here it is if it is not in there then i should do the tracings and otherwise if it is in there then the offsets let's set it both to zero good so here we are gonna do a sphere trace by channel we are gonna use the visibility channel and for now i'm gonna put this at one frame now we need to do two traces one for the left foot and one for the right so here i need to know where my sphere trace starts and to get this start and end locations we can check the control rig that if you forgot where it is should be wherever you have your skeletal mesh and the way this is doing the foot trace here we have the sphere trace by channel and the start and the end so we are just getting the bone in this case the foot bone the ik bone that we don't have but we will use the normal bone and we are getting the x and y value the set value will be the root bone and we will add it 30 so it will start let's just draw it so it is easier to see this is the bone and let's just put it like this this is the bone from here we are getting the c value of the root bond that usually is here so the c value will start here but we add in 30 so let's say this is 30. units and for the end part we are subtracting minus 50. so this is the range of our food trace so let's do this we can close that we are going to have to get the value of the bone so let's find if i put bone and i get the value of the bone here hopefully i can get bone location let's see what was the node now oh the node i was looking for is the get socket location to use it here i'm gonna copy and paste this get pan gonna cast it to a character now from here let's get the mesh and from the mesh we have get socket location even though it says socket it gets socket or bone location so i need a bone name let's show those names we have foot r let's get the food r let's get the food l and let's not forget about the route right we can't hide that the names now great so now we will start with what the right foot we need the x on y locations we can break it like this we can also right click and split these pins and we are gonna make a vector this vector will have the x and y locations of this foot and also of the root the c value of the root now i wanted to add for the start 30 units so here i can add 30. for the end also gonna make this and also going to use the x y but instead of adding i wanted to subtract and i was going to subtract 50 units because that's the numbers i got from the control rig now the radius believe the control rig was using three a really small radius you really don't need that much and for now let's just test it let's press play we have an error let's see what's our error here forgot about connecting this let's compile it save it late and now i see that i have this trace and i should stop seeing it whenever i jump but this should already give me the location that i need for example here or well in in this case if i'm looking like this right so i'm gonna use this out hit and if it is true then i'm gonna break this i'm gonna get that impact point and that's going to be my offset if it if it is showing some clipping then i'm gonna use just the location right so let's just try it for now this is with the foot right so let's change the foot right offset the impact point is this one let's compile and this didn't happen like i was hoping so what happened let's use that location and right now it's colliding but it is not the way i was expecting of using it i now need to compare the offset and see if my oh the one first these foot offset i only need the c value that's uh that's on me i only need the c value and let's hmm let's now i will debug it to see what is happening now and i was debugging it but it is working correctly i was printing the the value here to check why do i say that it is working correctly because it is working the other way around let's do something like this and we have this other movement right now it should look like correctly but what we were missing well i was missing is moving the pelvis around so i can match this movement i realized that here in the control rig we do not only set up the offsets of the feet but also the offset of our pelvis and then we can manipulate it so in order to do that with our character we need to go back to the ik rig of the cleric go to the pelvis set a new ik goal be sure to be selecting this full body okay before doing that this big pelvis goal will let us do this movement now let's save it let's put this and expose it and also here in the anime graph i'm gonna select the pelvis goal position promote it to a variable call it pelvis offset and i'm going to whoops go back to the event graph and here [Music] this offset should also go to the pelvis i'm gonna leave it like this for now just to see if it is working and i see that it is working in the other way the other way around so i need to negate this value this value i could also just multiply this by change the pin to a float minus one and just do it like this and let's see now if it works correctly or not and it would seem that it does but my my capsule it's working against me because i have this collision and it's not doing the thing i want it to do so i need to change my approach so i was looking for another approach but then it hit me i have been doing some calculations wrong why because here i'm just printing the impact point and it's always the same value because it makes sense that whenever it hits in this case it will be the same value unless it changes to this so what i need to do now or what i need to fix is that here here is my root and here is my well should be my new position of my feet so i need to check this offset and i just need to subtract this value by this value and i will get it so in order to fix whatever thing i did here and i'm just gonna delete this so it is easier for you guys to see this sphere trace is fine that works correctly this is not in it i was just messing around with that now what i need to check if if i'm how much is the value between this root position and this impact point so i do still need to check this value and i'm going to here this value of the root this c value i'm gonna subtract it by the impact point if this doesn't work i'm just changing it changing the values but it i i don't remember how i fix it but we just need to know the value between these two values so that's why i'm just subtracting it now let's get our i was doing it with the right foot right yes so put our offset through here and i'm gonna connect it like this i just need the c value gonna press play and see if this works correctly if it doesn't if it is going upwards then i mess up and it should be the other way around now let's press play and now my feet will try to stay in the ground as long as it can and now here is where the hip displacement well the pelvis offset enters it should be exactly the same value and now we have it there it is right now it's not working with my other feet with the left one but all i need to do is just follow the same the same the same steps so what did i do here here i'm setting an offset and i could easily change this [Music] to a function but do i want to do that or do i want to take the easy way out okay i'll do it i'll do it for you guys just to keep your code clean so i will make this into a function this way i'm gonna select this and yeah for now it's okay it's okay i'm just selecting these operations and there's going to be yeah yeah now i i have i have it in my head now this in order for me to eat to be easy to now my english is failing in order for changing this into a function easily i will first make a vector well break a vector like this break vector and i'm gonna pass this here the y here i'm gonna make this recombine it into a vector and do it something like this copy and paste it this also was going into c right yes see control drag click and should work recombine okay now it should be a lot easier because i only need to pass a vector here and i will get i should get a vector from this so let's make this or well make vector i just needed this node this will be the c node i will recombine this like this and now instead of using this if statement i'm gonna use this select and it seems i can only select a vector okay let's select the vector if this is true i will pick a so a will be this value if it is false then i want to pick b which is 0 0 0 with which makes no change at all so something like this i'm just doing some quick conversions in my code so i can convert it into a function which without too much trouble now so now i have i will have an as an input two vectors as a and as an output one vector i can select all these now right click it collapse to function this will be the food trace my fir first vector should be named put and location the next one should be root location and the return value should be the offset now i can first do it like this for the food trace for the food are and before changing the pelvis this part is important i need to also do the food trace for the left foot under root is the same now i need to put my left foot here set it up and now i need to check which of these offset is the greatest and depending on which one is the greatest i will set it up as the pelvis offset i will use the same select node here so select select vector and the way i'm gonna compare it is just getting these two values splitting them and if the left offset is greater if it doesn't work with greater we just change it to less and that's it if it is greater than c of the right offset then we will pick a and a will be the foot left foot offset and b will be the right foot offset let's check if this works um here it's not working exactly well so we can change it like this or we can change it the other way around so i believe that that should be easier and now it does work as we expected yeah so i told you if we didn't work at first we just need to change the values either that conver convert that less to to excuse me that greater than to less than or just change the outputs now we just need to remove this and at least make it a little bit more clear something like this compile it save it we don't we shouldn't have any more problems and here it is ik fit without the ik bones by using the ik rig asset pretty cool right and let yes let's do this little test where the yeah shouldn't work there if the a if the ledge is too big then it shouldn't work the ik shouldn't work that's pretty cool right now oh it's three in the morning i started at 12 a lot of trouble shooting but it is worth it because we now can use ik with any character really so that will be it for this video we have learned how to make ik with a character without the ik bones and a character with the ik bones by using the ik asset and also by using the control rig like the way epic gave us that that template so leave a like subscribe you can also become a member if you can if you yeah if you can support us and if you like what we do we are still wanting to give more free content and i would like to to thank everybody that have become a member it really touches our heart so yeah we'll see you in the next video
Info
Channel: UNF Games
Views: 53,334
Rating: undefined out of 5
Keywords: unfgames, unreal engine beginner tutorial, unreal engine 5 tutorial, foot ik tutorial ue5, foot ik tutorial custom character, foot placement tutorial unreal
Id: lfU3p80EjQE
Channel Id: undefined
Length: 108min 46sec (6526 seconds)
Published: Sat Apr 23 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.