UE 4/5 Turn In Place | Using Animation Curve

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to youtube for you so in this video we will set up this turn in place functionality as you guys can now see my character will properly perform turn in place 90 and turn in place 180 animations in all directions and there is no foot sliding involved and my character properly perform the turn in pace animation so we are using the animation curves to extract the animation data and perform turn in place animation and this is not root motion based everything is properly working by using animation curves there is no root motion involved in all of this so let's get started guys so here's my default third person project and all i have changed is just the idle animation and everything is same so now let's go ahead and open our animation blueprint go to event graph and over in my event graph i'm gonna use get try get pawn owner and castro third person character i'm gonna promote this to variable and call this player so from my player i'm gonna get my base aim rotation and get actor rotation i'm gonna use delta rotate break the rotator and here is my yaw i'm gonna promote this to a variable and call this your delta like so so here's my yaw delta if i go ahead and print this out you will see that if i turn my camera towards right the rotation is in positive positive axis and if i turn towards left the rotation is in negative axis so we will use this information to properly perform our turning place animations so now i'm going to go to my animation graph and here is my idol run straight i'm gonna disconnect it over here and add new state machine open my straight machine add straight and this will be my idle and over here this will be my tongue left turn right and from here this will be my turn left i'm gonna copy the same blend space and paste it into my idle state like so and i'm gonna use this turn right and turn left to perform my turning place animations so now let's go ahead and find our animations so i have my i have these root motion animations the this will be my turn right 180 and this will be my turn left on it sorry turn right 90 and similarly i have the left and right animations so we're gonna use this first we're gonna open our turn right grab our turn right animation turn right 90 and put it over here and from our turn left i'm gonna get my turn left 90 and put it over here so now let's use blend pose by bool so i'm gonna grab my your delta and get the absolute value so if my absolute value is greater than let's say 135 then we will perform turn right 180 animation otherwise we'll perform turn right 90 animation like so i'm gonna copy the same notes from here open my turn left state and from the absolute value if my your delta is greater than 135 then we'll perform turn left 180 otherwise turn left 90 like so so for our conditions i'm gonna open my character blueprint and here is my turn axis i'm gonna promote this to a variable turn rate so this will be used for our condition i'm gonna move these nodes over here and from my player i'm gonna get my turn rate if my turn rate is equal to zero only then i'm gonna promote say i'm gonna i'm gonna perform turning place animation like so so if we are continuously rotating our axis then we will not perform our turn animation and if our turn rate is equal to zero then we will perform our can turn animations from our idle to turn right i'm gonna open the conditions and from my condition i'm gonna grab my yaw delta if my delta is greater than 45 and can turn is true then we will perform turn right animation and from turn right to idle i'm gonna use the automatic rules to draw open our animations and set the loop animation to false and from idle to turn left i'm gonna open the conditions and the condition will be my if your delta is less than negative 45 and can turn is true then we will go to turn left straight and from turn left to idle i'm gonna use the automatic rule based condition and on in my turn left side i'm gonna set these to loop animation to false so now let's so here we have setup i'm going to repeat the process we will we will use the turn rate variable and if turn rate is equal to 0 then our canton variable is true and from idle to turn right if our yaw delta is greater than 45 and turn can turn is true similarly in our turn left case and now if i gonna if i'm gonna play this you will see my character is properly performing the desired animation but it not it's not performing the it's not turning properly so for this i'm gonna we will use the animation curves to extract the rotation data from our animation curves and then we will use that rotation data to perform our turn in place animations so for this i'm gonna open my blueprints and i'm gonna right click and create a new blueprint class this will be my animation modifier we will use this animation modifier to extract our rotation data from animation so i'm gonna call this rotation extract and from my functions i'm gonna write on right click and promote the animation sequence to variable and after that i'm gonna add curve the curve will be my rotation yaw curve type will be plot and i'm gonna use for loop get my animation sequence and get number of frames first index will be zero and the last index the total number of frames after that i'm gonna get my animation sequence and use get born pause for frame the bone name will be my root the top one of your hierarchy this will be in my case this will be the road and the frame i'm gonna use the index value and i'm gonna turn this to true extract root motion split the struct pane split the rotation and now i'm gonna grab my animation sequence and get time at frame at the this frame what will be the time and at that time i'm gonna add curve at float curve key the time will be this and for value i'm gonna use map range clamped and for value the value will be my yaw from my get born pause for frame in range is from 0 to what will be the last i'm gonna use the get this is this will be my last frame and the in range is zero and the last range in range b will be my yaw from my last frame i'm gonna map this to zero to one so i'm gonna map the whole rotation from 0 to 90 or 0 to 180 to 0 to 1 over here so now if i'm gonna compile save this and open my turn right animation go to my window and here is my animation data modifier i'm gonna add motiva modifier that will be my rotation extract now i'm gonna right click and apply the modifier but it's not working let's find out why because we will not set the curve name over here the current name will be my rotation yaw so now if i'm gonna compile save right click and apply modifier now you can see here is my rotation curve from zero to one i'm gonna add this rotation curves to all my turn in place animations like so add modifier apply modifier and here i'm gonna save all save this and here is my rotation data from my animation is map from animations to this curve i'm gonna add a new curve over here i'm gonna call this turn in place so each of my turning page animation i'm gonna add this curtain in place and set the value to one like so similarly to all my animations i'm gonna add and set the turning paste to one so by doing this we will determine when we play this animation the turn in place animation curve value is one i'm gonna add this metadata to all my animations like so so here's the animation curves part is completed now we will set our logic to perform to extract to use this data and perform the turning page animations so over in my event graph of my animation blueprint so i'm gonna move these nodes over here and we will get our curve value i'm gonna first get my turn in place curve value like this i'm gonna get my turning place value so if turn in pace is zero so which means we are not performing our turn in place animations only then we will set our your delta so if we are performing our turn in place animation then we we then we will no longer set our your delta variable and after that if we are performing the turn in place otherwise if turn in place is equal to 1 which means we are performing turning place animations so for this case i'm gonna use another branch and get the car value now this time the curve will be my rotation your curve i'm gonna get my rotation yaw curve check if it is greater than zero if it is greater than zero then we gonna then we will use a sequence node so from this i'm gonna use do once from blue ones node i'm gonna get my player character get actor rotation and from the yaw i'm gonna promote the yaw to a variable which will be my current yaw so this will be the current yaw value of our character when we perform the turn in place animation so at first frame we will get the current yaw value and the target yaw will be my i'm gonna get my player character get base aim rotation and this will be the desired yaw i'm gonna promote this variable i'm gonna call this target yaw so at first frame using do once we will get our current yaw and the target value after we getting this value we will use the get player and set actor rotation like so the rotation will be i'm gonna use the ease node for this the alpha will be our cat car value from the rotation here because we have set this to zero to one value as you guys can now see when we perform this animation my rotation here is map from 0 to 1 so this will be used for my alpha to perform the proper rotation from current rotate from my current actor rotation to desired rotation so i'm gonna use this use this value to my yaw and from my alpha i'm gonna make the rotator for both cases the from a i'm gonna use the current yaw and the b i'm gonna use the target yeah like this so let's quickly check this out here you guys can now see my character properly turning so now let's reset this nodes so that each time we perform the proper turning base animation so i'm going to use the sequence node over here so if we are not performing the eternal base any animation anymore if we are not playing turning place then we will set reset these nodes over here and also i'm gonna set the yaw delta to zero when we have set the actor rotation so whenever actor rotation is properly set then we will set the yaw delta to zero so now go ahead and play here you guys can now see my character properly perform turning pace animation and it's a simple technique you need just animation curves to perform that there is no foot sliding over here so now let's fix some things over here i'm going to open my turn right and i'm gonna set the play rate to 1.25 for my both cases and now let's check so it's not performing the one eight turn 180 animation it's just performing the turn left 90 or right 90. so what's the reason i'm gonna check the i'm gonna check the yaw delta each time we perform the animation what is the value of your data i think this is not good by setting this to zero yes when but we need to set this to zero i'm gonna [Music] disconnect these nodes from here and i'm gonna connect this again to over here and so we will using the yaw delta to determine our turn 180 or 90 animation so instead of using this variable we will use another variable for this so for your delta that we are setting over here i'm gonna get my absolute value from here and if my absolute value is greater than 135 or whatever angle you would like to set i'm gonna promote this variable i'm gonna call this perform 180 perform 180 turn place animation like so so this is all the logic that we have set up over here there's currently setting up the your delta and setup the either we perform the 180 turn in place or 90 now we're gonna go to our turn right instead of using the your delta i'm using perform 180 variable to both my left and right cases so now if i'm gonna go ahead and play and you can see my character is properly performed turn in place animation and there is no foot sliding involved and everything is properly working fine so i hope you guys like this video don't forget to subscribe the youtube channel and also you can support me on patreon and gain all the project files and contact me over there thank you guys and see you in the
Info
Channel: TechAnim Studios
Views: 23,361
Rating: undefined out of 5
Keywords: UE4, UE4 Turn In Place, UE5, UE5 Turn In Place, ue4 tutorial, ue5, unreal engine 5, turn in place, ue4 turn in place, animation, animations, turn, turning, unreal engine turn in place, direction, movements, how to turn, UE4 Animation Curve
Id: PvUqGqqgg7U
Channel Id: undefined
Length: 26min 52sec (1612 seconds)
Published: Tue Apr 19 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.