UE5 - Basic Locomotion: Crouch Animations (REPLICATED)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
house up guys so today we're going to continue our Locomotion system and we're going to implement the crouching and we're going to replicate it so uh let's begin the first thing we need is to import the animations so let's go to characters mannequins animations many unarms and we're going to create a new folder called Crouch so now uh get the animations that are on the description the Crouch animations drag them in select the skeleton import all so now that we have them uh select them all right click asset actions bulk edit go to root motion enable and force root lock file save all so um now we need to rotate some animations like we did in previous videos let's go to the walk backwards left animation this one um so now uh over here we're going to say 45 and change this to animation first frame re-import animation like this now the backwards right will be minus 45 so minus 45 animation first frame reimport animation now the forwards left um will be minus 45 animation first frame re-import animation and the forwards rights will be 45 animation first frame re-import animation so now save all um now we need to fix some animations position so let's go to the walk right animation and here it will be 15 on import translation and here it will be minus 10. so animation first frame report animation so you can see it moved a little now we can go to the backwards left animation and do the same thing on import translation this will be minus 15 and here it will be 10. so re-import animation and it should move so now we need to rotate the spine so we can start here on the backwards left we can pause this move it here skeleton tree spine one here it will be 20 and here it will be 5. add a key save now the backwards right [Music] um 20 5 add a key save the forwards left 25 add a key save and the forwards right 25 add a key and Save so um now that's it now we need to add the sync markers I know it's boring let's begin on the walk backwards so it starts on the left so add sync marker left copy this one right left right left right left left uh right left right left right left so now we can copy this once into the backwards left and backwards right animation like this um now the walk forwards which starts on the left copy this one right left right left right left left right left right left right left so now you can copy these ones into the forwards left and forwards right like this um now the walk left which starts on the left copy this right left right left right left left right left right left right left so now the walk right um at sync marker left starts on the left copy this one right left right left so left right left right left so that's it now we can create our blank space so you can close this go to animation blend space select the skeleton call this blend space mail um how do I yeah mail unarmed whoa okay unarmed Crouch sorry about that so open it up now let's go to asset details the horizontal axis will be the direction from minus 180 to 180 will have 8 crew divisions snap to grid now the vertical axis will be the speeds from 0 to 600 will have eight divisions snap to grid now the weight speed down here uh where is it yeah it will be five and that's it we can start uh dragging our animations so the Crouch forwards will be here on 225 now the forwards left forwards right walk left walk rights backwards left backwards right backwards and backwards so that's it now we have um our blend space so now we need to create the replication for this so let's do that let's go to our character so content third person okay we're going to do uh same thing we did before so um the first things we're going to do is create a variable called crouching this will be replicated here okay and now we're going to go to the replication graph we created before uh we're going to copy the this events we created before and we can call them Crouch on clients Crouch on server Crouch off clients and Crouch off server so now let's change the client events to run on client like this in the server wants to run on the server like this so uh now all we need is just to grab the variable set and copy this to each event and connect everything so we don't need a function in this case because we only need to set the variable we don't need to do anything else so it just stays uh easier like this so um now on the on events when we want to turn it on we just set the variable to true and we can comment this and say crotch okay so um right now we just need to go to the event graph and get a key it could be the left control key yeah like this so if uh we are crouching so get the crouching create a branch okay so if we are uh crouching we want to turn the Crouch off so we can say um Crouch off server first and then um Crouch off client so um now if the crouching is not turned on we want to turn the crotch on so Crouch on server and crouch on client like this so um we can comment this and say Crouch so uh something we also need to do is make sure um this ones work well together so when we press the Sprint for example we want to turn off the Crouch and when we Crouch we want to turn off the Sprint so let's just expand this a little bit for both and as I said if the Sprint is on we can copy the crotch off functions and sets the Crouch to off so when you start sprinting we turn off the crotch uh the same thing here so if we start the Crouch uh we get the Sprint off events and we call them here and we turn off the Sprint so that's it um now we can go to our animation blueprint and get the crouching variable that we created from the character and use it to switch between blend spaces so let's do that let's go to the animation blueprint content characters mannequins animations many and let's go to the event graph um here let's go up here and delete these casts let's go to references change this character to thirds person character okay object reference change variable type so um now if we do a cast from here so casts to third person character we can now get the variables from our character okay so that's basically it now we're going to add a pin right here and down here we're going to get the character and say uh crouching like this so get the crouching and we're going to set a variable on the animation blueprint called crouching so and connect this up here um so and that's basically it so we go to our character gets the variable from there and then we set the same variable here on the animation blueprint so comment this and say character variables like this so any variable you need from the character you just do the same thing and expand this and add it here so um now we need to go to our animation graph and the first thing we are going to do is just duplicate this Locomotion State machine like this rename it to crouch like that open it up go to the idle delete everything and get the Crouch Idol animation connect right there and then let's go back to the walk and run and do the same thing but delete just the blend space and get our new blend space that we created connects everything connect the results so and that's it now we need to go to the animation graph and we're going to say Blends by bull okay and we're going to connect our crouching variable right here so and what this does is so switch between poses based on a Boolean valve which will be the crouching Okay so we can also connect the results right here and now if we are crouching so if crouching is true we use the Crouch State machine if not we continue to use The Locomotion we created before okay that's it we can drag this here to keep things organized and that's it now we should be able to use the Crouch so let's test it out hit play and if I press the Ctrl okay so you can see this is really fast and that's because we need to change the blend times between the animations so let's go there on the animation blueprint the blend poses has two blend times so we're going to set this to 0.3 and here the same thing to 0.3 now compile save let's play again now if I press Ctrl it should be way smoother and as you can see we can also walk in all the directions uh we can also jump and if we press shift to Sprint we can start sprinting and now if you press the Ctrl key we start crouching so that's it this is how you can implement the crouching but you can also test this on the server if you want so go to two players here listen server play and as you can see now if I press Ctrl I'm Crouch um I can walk around and use all the animations and as you can see um now I can use everything so that's it I hope you liked it uh I hope you learned something with it so don't forget to subscribe
Info
Channel: Native Coder
Views: 5,162
Rating: undefined out of 5
Keywords: ue5, unreal engine, ue4, metahuman, metahumans, meta-human, integration, fast, quick, new, method, new method, videogames, development, advanced locomotion system, marketplace, locomotion, advanced locomotion, tutorial, easy, replace character, retarget, animations, basic, 8-way movement, movement, lyra, strafe, replicated, beginner, crouch
Id: ovMRm2DfQqM
Channel Id: undefined
Length: 15min 19sec (919 seconds)
Published: Tue Sep 26 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.