How To Use A Custom Player Character (Metahuman) - Unreal Engine 5 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys mof frizzo here and in this tutorial I'm going to be showing you how to set up a custom character in Unreal Engine 5 so this could be a character from anywhere miimo or wherever in this case we're going to be using a metahuman and we're going to be setting this character up from scratch and creating an animation blueprint from scratch so that it acts just like a character would in the third person template um it's not super basic but but if you're a beginner to unreal I promise you this is going to be very easy to follow I guarantee you you will be able to replicate this in your project so without further Ado let me show you how to do this okay so I'm going to create a new project using the third person template leave everything's default and I've just called this one my characters project going to hit create and once the editor has fired up I'm going to head on over to quickel bridge by clicking up here and quickel Bridge and head on down to the metahumans tab and I'm just going to add a metahuman that I've already downloaded so if I scroll down here I believe I already have tray downloaded if uh if this doesn't say add and this isn't grade out you just need to download it so you might want to click your character select the quality you want to download it in hit download and then add to project with that added you'll find this metahumans folder down here if you go into your metahumans folder and your metahumans blueprint the first time you open this it will prompt you to enable some missing plugins enable all missing plugins and then you'll be prompted to restart the editor so hit restart now all righty the editor has restarted so I'm going to go ahead and open my metahumans blueprint I'm also going to find the third person folder and blueprints and open BP third person character and BP third person game mode next thing I'm going to do is go to my metahumans blueprint and in class settings I'm going to change the parent class to character now that the parent class is character I can take the body and drag it onto mesh I can select the root and hit delete I'm going to hit compile and it's going to come up with this error here you can click on target target here requires mesh so grab mesh drag it onto Target that should get rid of that error and then now that this has being parented to character this is a character blueprint we can go to the BP third person game mode and change the default porn class to our metahumans blueprint that's all we need to do in here we can compile save and close that the next thing we want to do is if you go to the viewport you'll see that the character isn't lining up with the capsule component here so what we want to do is select the body and here we're going to put in the value on the third argument here on location we're going to put 96 and and this will be90 to get the rotation pointing the same direction as this Arrow component here you'll also notice here that the capsule component isn't big enough to fit our character this is going to be our main thing that collides with the world and objects Etc so we want to select the capsule component here we want to change the capsule half height let's change it to 96 and we can change the capsule radius to about 50 might need to come down a little bit lower than that so no actually that's fine the way it is we can select LOD Sync here and change the forced lood to zero this will stop the disappearing Grooms problem because there is certain loods of the Grooms that just do not exist with the metahumans so we're locking it to the lowest LOD here for now for now that's fine um the next thing we want to do is head over to the third person blueprint um and while we're here in the event graph let's just grab everything here in the event graph and control click event begin play to unselect that and then contrl C to copy go to our metahumans event graph find some empty space contrl +v to paste and then we just want to grab event begin play and hit hair L setup here and plug it into cast to player controller here so we're setting the um the enhanced input and the um input mapping context here on event begin play um we are going to add a few more things to that later on so let's just create some more space there and the next thing we'll do is go to back to our BP third person character we're going to grab the camera boom here and right click and copy and on our capsule component we can right click and paste that spring arm notice that it's not called camera boom here it's just called spring arm that is actually what that type of component is called now we could just add one of these but the beauty of copy pasting it from the BP third person character here is it brings with it all the settings that were on there so this camera and the camera boom is going to act exactly how it does in the third person template so we're also going to right click on the follow camera and copy that and then that's going on the spring arm here that hasn't um parented to the spring arm so just grab the camera and drag it onto to spring arm there we go um a couple of other things we want to do just to make this um act as if it would in the third person template is copy some of the character movement settings here so if I compile and save this and hit play we will have a character we will have a camera but you'll see he's rotating with the camera and um obviously there's no animations we're going to make an animation blueprint um but he's rotating with the camera here now this might be fine if you wanted to implement sort of strafing if you're doing a over the shoulder third person game where you do want them facing towards the camera but for now we're just going to set this up to work exactly like it would in the um third person template so we're going to select the we can just select the root and we can search for Orient and you'll find this Orient rotation to movement now that means the character will rotate in the whichever direction it's moving in we will also look for use controller rotation your this rotates the character wherever the camera's looking so these are the two settings that you want to play with if you were as I said doing some over the-shoulder sort of thing you would have used controller rotation you're checked probably and you would um also have this Orient rotation to movement unchecked but you'll see the differences here if I compile and save and hit play now the camera isn't rotating the character and whichever direction he moves is the direction he's facing the other thing you want to keep in mind is that the character movement here um that has been applied to this blueprint because we parented it to character um in the class settings when we made this a character blueprint this has basically just got all of the default settings here so these are the default settings for character movement gravity scale is at one whereas if you for example look at the BP third person character gravity scale is at 1.75 the acceleration is different um there's a lot of things that are different the max walk speed is different the max walk speed should be 600 on here so these kinds of things you want to play with to get the character acting uh how you want it to in your game anyway so I'm not going to go through copying these settings over to here it's literally just a case of looking at what is different and then changing it over here in your metahumans blueprint um there might be a couple of things we'd like to change um max step height I wonder if that's any different no that's the same a lot of this stuff is the same I did notice that the gravity was different and the mass is different so for example if you're worried about how high your character is jumping um mass in oh this is this is usually unchecked ah it's because it's in character movement sorry you have to select the root and if you search for Mass you'll see that the mass here is set on on the whole blueprint on the on the root as just about 210 kg whereas if you look in the root of the third person character it's 120 so that's one thing that you might want to just change let's set that as 120 um but the gravity scale is also lower Ah that's fine that's fine how it is so let's go on to anim and I'll show you how to animate this character and we will start by retargeting some animations from the third person blueprint um if you go into your metahumans folder and then common and common you'll find this RTG metahuman ik retargeter we're going to select that and hit control D to duplicate and we're going to change this to RTG many to metahuman something like that something that differentiates it from that we're going to open up this RTG many to meta human up in the top right here we're going to change Source ik rig asset to ik mannequin and Source preview mesh can stay as many going to change Target ik rig asset actually can stay as ik metahuman this target preview mesh is going to be the preview of the body that your metahuman is using so so if I select the body on my metahuman here you'll see over here the skeletal mesh asset is M tall normal weight body M tall normal weight body we want to use M tall normal weight body preview right here so you can see the preview of this mesh right here uh one thing that is very important here in the latest version of Unreal Engine in 5.3 is that you select the root here and change translation mode to globally scaled this is so that the root motion on the running animations uh isn't broken when you duplicate and retarget the animation assets so right now it's previewing um the retargeted pose onto Manny so that's why it pretty much lines up but if you click up here and go to edit retarget pose this is the pose that it's retargeting from so we're just going to pose this mesh really quick we want to click on character up here and Bones all hierarchy that will make the skeleton appear and then we can select the upper arm here and we can make sure rotation rotation snapping is switched on and to 5° we're going to select this bone here and we're going to rotate it back 15° and out 10° just just like that so you can see this arm lines up a lot better now we can do the same on this side rotate it back 15° and rotate it out 10° and then you can see that the forearms and the hands don't line up great it doesn't matter too much but just for the sake of um you know making a bit more of an effort here don't know what I've done there haven't selected the upper arm make sure you select the sorry the lower arm select the lower arm bone here and we're going to rotate it out 10° um sort of forward 10° and up and back 5° it's just more so the hands line up here uh that's not quite right that's undone that side sorry let's start again on the lower arm here so we're going to rotate It Forward 10° and out 5° just like that same on this side rotate It Forward 10° and out 5° we're getting pretty close now but if we look at the hands where are the hands sitting it's a little bit low if you select here at the wrist it's a bit tricky to get sometimes cuz with all this oops I accidentally rotated something there contrl Z to undo that trying to find the root of the hand here ah here it is right up near the wrist accidentally doing some rotation when I'm supposed to be just moving the camera here oh it might be my mouse wheel so let's select the wrist here the hand and I'd actually say that that's pretty good where it is if we select character up here bones and none get rid of all the hierarchy of the skeleton yeah that's actually pretty good the fingers even line up pretty well so if that's the same on this side which it should be that's absolutely fine just like that all righty so that's all we need to do in here we can save this and close this and then what we want to do is find this characters folder mannequins animations and here because ABP Quinn is a child of ABP many ABP Quinn has references to all of the animations that ABP many also uses so we're going to duplicate and retarget ABB Quinn here what we might do actually is in content might create a new folder we'll call it underscore Main and then in underscore main create another folder call it animations and in animations create one more folder we'll call it third person anims just to keep this organized so that we know where these animations came from so back in characters mannequins animations we're going to right click on ABP Quinn and retarget animation assets duplicate and retarget animation asset SL blueprints select the retarget that we created which is RTG many to metahuman and we're going to change the folder here so click change and find the folder we just created main animations third person anims click okay and retarget this is basically uh retargeting all the animations referenced in these animation blueprints onto our metahumans skeleton so the first thing we can do straight away is Select ABP man and ABP Quinn and hit delete we are not going to use those animation blueprints we just duplicated those so that it duplicates all of the animations there in if we uh open these up you'll see we've got a bunch of animations that have been retargeted onto our metahuman skeleton here which of these are going to come in handy just as a base setup and you go on want to add other animations or create your own animations afterwards but we're going to use these in our animation blueprint which we can create right now we can just right click here and find animation animation blueprint once again you'll want to select the skeleton that your character is using so for me that's metahuman base skeleton and hit create and I'm going to call this abore tray which is the name of my metahuman actually I might just drag this out to animation the folder above and just move here and I'll just keep the animation blueprint here in the animation folder we can open that up and the very first thing we're going to do is head over to the event graph we're going to set up some logic in here so you can right click and find event blueprint begin Play We also going to grab this try get porn owner and off of try get porn owner owner you can find an is valid this one plug in the execution pin here and also of Tri get porn owner we are going to cast to our characters blueprint and as the characters blueprint there we can promote that to a variable and we can just call that something like character reference so what this does is on begin play it's uh checking that there is a porn owner if there is a porn owner casting to uh the player character here the um metahumans blueprint and then creating a variable which is a reference to that character so instead of every time the uh animations update we instead of casting casting casting over to this character we just cast once on event blueprint begin play and create a ref reference to that character um also off this character here we can get the character movement um it might you might have to scroll down to the bottom here get character movement and then we can also promote that to a variable and just leave it as character movement plug that in there now down here we're going to get our character reference and once again we're going to check is valid plug in the execution pin to this event blueprint update animation and on the is valid here we're going to find a sequence and we're going to add a bunch of pins to this sequence because this is where our our animation blueprint is going to um call over to our character and grab a set of variables which it will then use to dictate which animations to play um so the first one we can get is if we just get our character movement get character movement and then is falling this is kind of a built-in function in the character movement that checks whether the character is in the air very useful in animation so we can promote that to a variable call that is falling question mark we can plug that into the first pin there then we can get our character reference here and get velocity we might have to scroll down to the bottom get velocity and then promote that to a variable call it velocity also off of the get velocity we can get the vector oops Vector length XY promote this to a variable and call it ground speed so it's just checking the vector length of our character's velocity on the X and Y AIS to get its speed relative to the ground we can also drag off of the character reference here and get rotation whoops get rotation no sorry get rotation get actor rotation right here and then off of get actor rotation we can calculate direction it'll be this one here one that says Target is anom instance plug in the velocity to the velocity up here and you're going to promote this to a variable and call it Direction plug that into into the next execution pin this is getting a little bit cluttered here but it doesn't matter too much as long as like personally I just like to keep these set variables in line here so this will be my list of variables right here and then you can look back to how that calculated um the very last thing we want to do here is a should move Boolean um if we just get the Char movement and then uh what we can do off of that is um get the current acceleration we can check if the C current acceleration is not equal to zero and if our ground speed is greater than three then this we can promote to a variable and call that should move question mark this is just a Boolean that will allow us to transition from an idle animation into a walk and run animation so it's just making sure that there isn't some small amount of movement triggering a walk or run animation we want um the acceleration to be greater than zero and the ground speed to be more than three and plug this into the last execution pin here we don't need this one for now and that's it this is all we need to set up our enm graph to play the basic animations of walking and running and jumping and falling and so on and so forth so let's let's go ahead and do that right now head on over to the animation graph and I going to right click up here in some empty space and type in state machine and we're going to add a new state machine here we can click on that and we can call that locom motion while we're here we're also going to drag off of there and case this so new save CED pose this is basically and we can click on that and we can also call that Loc motion this is basically just saving this pose output here into a cache so then we can use it somewhere else um this is a good practice in certain uh situations here you'll you'll see why in a moment we can go into our Locomotion here and on Entry we can add a state and we'll call it idle and in idle what we can do is grab our retargeted idle pose there's two here there's m f for the female and there's mm for the male I'm just going to grab the male idle pose here and plug it in if you want to see the differences you can open them up they're they're slightly different and make sure with mm idle selected you check Loop animation over here so this animation is just going to Loop um we can back out to Locomotion and off of idle we can add another state and we'll call it walk SL run and just before we add the animations here in walk run I'm going to drag off of the edge here and back to idle and these are our transitions so these are the rules that need to be satisfied in order to transition to another state and the Only Rule we need to trans uh transition into Walk and Run is should move so we can grab should move and plug it in there and if we go back out to Locomotion and the transition rule to go back to idle will just be should not move so grab should move find a not Boolean plug that in that's all we need to do there so we can back out to Locomotion and go into walk run here and then you'll see these blend spaces here which we retargeted we can just grab blend space mm walk run plug that in there and grab our ground speed variable plug that in there and that's all we need to do there if we go back out to our anom graph and we just right click here and find Locomotion use CED pose Locomotion and plug this into the result here we can compile and save and now our character oh he's not animated because we haven't selected the animation blueprint yet so in the characters blueprint select body and over here animation mode should be on use animation blueprint and the anom class will be the animation blueprint that you've created which for me is ABP tray and our character is animated we compile and save that and hit play there we go he's got his idle animation he's got his walking and his running but if we jump nothing happens so we also need to add jumping animations all righty in the animation blueprint what we're actually going to do is we're going to delete this and we're going to just add another state machine here and we're going to call it main states and instead of just connecting it straight to this output pose here we're also going to get a default slot slot default slot this is going to be the default slot into which any uh animation montages are overlaid onto onto the character so if you're ever going to use animation montages which you probably are you're going to want one of these slot default slots here in main states here we're going to go in here and off of entry we're going to um add a state and we'll call it Locomotion Locomotion just make sure I spelled that right and in Locomotion we are just going to find our CED pose Locomotion and plug that in there so we can back out to main states and what we can do as a bit of a cheat sheet is just open up our third person character uh animation blueprint so if you open the BP third person character and then click on the mesh you'll see ABP Quinn is the one it's using over here you can browse to that and open that up and then head on over to ah this is a child of ABP man so we actually want to open up ABP man and the anom graph and if we go into main states you'll see the setup that we have here now these are using uh what are called State aliases so two falling here and two land are actually State aliases they are basically a state but instead of having a transition to it uh what it's got is just over here a list of the other states and you can check the ones that you want uh to be able to transition to that one from if that makes any sense so this one has Locomotion and land checked that means Locomotion and land can both transition to this state Alias or one of the states that it's connected to as long as those conditions are met so it's just a neater way of organizing this instead of dragging that onto there onto here or here and this one also onto here and here we've just created this state Alias so we're going to do the same thing uh we can create a state Alias call it two falling and we will also create a state here called land uh another state Alias here called two land whoops and we're also going to uh create States called jump and fall Loop so up here we've got jump over here we've got full loop and jump into full loop and we just want to make sure that these State aliases have the right States checked so in two falling we want Locomotion and land um because you're either on the ground walking or maybe you just landed and then you fall off a ledge or something um so you want to be able to transition into these from Locomotion or land and to land we want to be able to transition into that from jump or fall Loop and I'll just double check that that's yep jump and fall Loop all good so we want to add the animations here and the transition rules okay so let's start with jump jump is going to be two conditions so we're going to get an and Boolean and the conditions are going to be is falling don't let this name um sort of misguide You by the way is falling just means is in the air so you could call that is in air if you like but uh we just call it is falling we also want to get the velocity and we want to split the struct pin here and we want to check if the velocity on the Z axis is greater than a certain amount amount uh let's just check what they use in ABP many so this transition here is falling velocity Z greater than 100 so let's use the same greater than 100 and that is our transition rule to jump our transition rule to the fall Loop will just be is falling and we'll just double check that that's correct is falling yep and jump to full loop will be is not falling I believe oh that's not even set up that's strange Ah that's an automatic transition that's why um so if I back out here and I just select this transition you'll see this automatic rule based on sequence player in State this basically means once the jump and animation is completed it can transition into full loop um and if is um this is not falling down here so sorry this might be a bit confusing for you jump to for Loop will be an automatic transmission uh transition automatic rule based on sequence blah blah blah is falling is falling and Z velocity greater than 100 automatic so these transitions are all done let's just add the animations while we're up here so this will be mm jump full loop will be mm full loop and as the name suggests this one needs to Loop in case we're falling falling falling so make sure you check Loop animation over here and that's all this top section set up now to land the state Alias transitions to land from jump or fall Loop which as you know these involve is falling so to land we just want this transition rule to be is not falling not Boolean so if we're not falling anymore we can transition into land and land land is actually an additive uh animation so mm land here will need to be applied as an additive I'm not sure if it will be the base or the additive um probably the additive I'm guessing and what we're going to add it to is The Locomotion so use C pose locomotion plug that in and from land to Locomotion will be an automatic transition so automatic rule based on sequence blah blah blah blah blah and let's just double check that that is correct uh should move should move is on there as well I'm not exactly sure why um or how to add there we go we just drag again to create two so we got the automatic Rule and should move um I I don't remember seeing that so I can't really explain to you why that is the case um but there it is but if we just control if we compile and save and hit play you'll see we've got the the walking and running and we've got the jumping animation and the falling animation he's going straight into the falling animation and the reason is ah this was the problem guys we have to set the priority order here so the priority order on this one is going to be two so that if we're in the air we probably jumped so the priority order needs to be two on here and I'll just double check that that's correct priority order one on jump priority order two on falling that was the error sorry about that now he's doing the jump animation and transitioning to the falling animation afterwards nice uh you'll notice one more mistake here with the beard not uh following the mesh properly um a problem with the binding assets uh even in UEI version 5.3 so let's fix that real quick uh what we're going to do is open up our metahumans blueprint and this section here that has event begin play we're going to just drag that down to the bottom and make a bit more space here also going to grab everything and move it away from event begin play and off event begin play we can add a sequence whoops my mouse Wheels playing around here sorry about that uh off of the sequence what we're going to do is we're going to then pull out all of these groom assets here pull them all out one by one like so eyebrows hair and beard and we are going to set the binding asset set binding asset can duplicate this a few times and I might just duplicate all three of those to save some time plug in all of the targets here and the execution pins and the first one into the next execution pin on the sequence there and just to make this foolproof to select the binding asset here what we're going to do is select the mustache and down here in the details panel we're going to find The Binding asset and browse to that and then with that selected we're going to go back into our characters blueprint and click this use asset browser selection to use the M the mustache uh binding asset now that this is selected here in the details panel we're actually going to clear that from the details panel of the actual mustache because we're setting this now on event begin play and we're going to do that for all of these so eyelashes browse to the asset go back to the blueprint set it here and then clear it over here and for the fuzz browse to the asset back to the blueprint set it here and then clear it here so on and so forth uno momento por for here and beard is the last one set it here clear it here and that's it guys we have imported a metahuman used it to oh the beard is not following along there what's going on sorry about that guys that was just a matter of uh closing the editor and reopening it uh I don't know why that happens just a little bug happens sometimes uh there we have it guys we have a metahuman in imported and ready to use as our player character with its own animation blueprint set up from scratch if this tutorial has been of any use or value to you whatsoever please hit like And subscribe and I will see you on the next one
Info
Channel: MizzoFrizzo
Views: 4,165
Rating: undefined out of 5
Keywords: unreal engine 5, ue5, video game development, true first person, animation, unreal engine tutorial, unreal engine 5 fps tutorial, ue5 fps tutorial, unreal engine fps tutorial, ue5 fps, first person shooter unreal engine 5, ue5 first person shooter, how to, make a game, make an enemy, use blueprints, make a fps game, 5.2, 5.3, first person shooter, metahuman, animate
Id: -tMxadBifpM
Channel Id: undefined
Length: 42min 45sec (2565 seconds)
Published: Thu Dec 07 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.