How to Animate a Character from Mixamo in Unity - Full Walkthrough

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone so today i'm going to record a little character animation tutorial because it's quite strange there are a lot of tutorials already online somehow none of them are quite holistic and work very well so every time i'm doing this right i'm going through a bunch of these videos and kind of picking cherry picking specific aspects um to create my my character animation from miximo it's quite strange but i thought this is a good opportunity to actually make this a little tutorial so as a holistic way of downloading models for and animations from miximo bring them to unity and actually make them work as simple as possible right okay let's get into this so i'm creating a new project all right all right so first things first um let's just create a couple of folders here scripts and prefabs and potentially a folder called import um and a folder inside which is called animation or animation okay cool um let's potentially download first a character from xml and its corresponding animation so let's go to miximo you have to log in or create a account and log in here um so if i go to the characters tab there's a bunch of different characters you can choose from um but i'll just gonna demonstrate it with this simple i think it's called xpot or something like that yep um and so i will download this model um it's just gonna be fbx for unity t-pose it doesn't really matter yeah i can download that right here okay and now we have to figure out what animations we want for our model so i'm heading over to animations and first thing is going to be walk like a normal walk forward what could we use walking i mean walking is just fine right i can actually look at it over here in the window how that actually going to look like um okay that's fine all right so that's the first thing i'm going to download this one fbx 30 without skin is fine download okay so then we need to walk backwards on backwards running backwards walking seems to be quite slow yeah i mean it looks a bit clumsy but whatever it's fine um in place i'm gonna download this one without skin is set already download great um the next thing we need is strafe so we want to strafe right and left right strafe walk yep that's cool download and then we need a left shave seems fine okay without skin and the last thing we need is an idol so don't do like the animation when the model is doing nothing okay so potentially this one maybe is there any movement maybe this one yeah that's cool i like that one all right without skin download great okay just waiting for this to download cool all right so these are all this is my model and those are my animations i'm just gonna pull all of these things into my unity animation folder cool so the only thing pretty much you have to do is you have to go through this animations and in animation you set the time or this loop time to checked so i'm gonna go through all of them unfortunately you cannot select multiple and then just apply okay cool that's my model that's all fine actually i don't as far as i remember i you don't have to change anything after that so that's cool so i'm creating a plane here for a second change the directional light to kind of a white ish and then bring in the spot model for a second okay first of all i'm going to pull it to to my prefabs folder okay and here i'm going to add a animator okay cool so that's all right then next thing i need is a actual animation so maybe i'm just going to place it in another folder it doesn't really matter you can sort it out um so animator controllers the next thing i need export controller so i can open it up by double clicking this controller [Music] this is kind of the basic basic setup so the first thing i need is a plant tree that which will be our movement and then i'm gonna create an empty called jump and i'm gonna make two transitions one from the movement to the jump and from jump to the movement then i'm creating two new parameters float which is called vertigo and another float card horizon don't know what the blend is doing here plan three all right it's probably gonna be deleted after i change the things in the blend tree and the last one is gonna be a bull which is jump talking of jump i think i forgot to download from miximo the jump animation so let's quickly do that how does that look that's a backward jump um maybe this one running jump i'm not sure maybe this one in place yep seems fine i'm just gonna take that one cool okay also taking the jump into my unity project okay don't forget to change the time to loop time apply okay cool so i guess like this one is the thing i could set up first so the transition that is basically triggered when the condition of the jump is true and when the jump condition is false it goes back to movement so the jump um here here i can now set a actual motion for what the jump is going to be i can just go here and try to find it in my assets right jump great that's it then i'm going into movement double clicking so i see my blend tree um i have to set my plenty to 2d freeform directional and then it's really weird delete this one yes delete here i'm setting a horizontal parameter and a vertical it's going to make sense in just a minute um okay and then i have to add a couple of motion fields so one i think so for idle and then for the four different directions that's yep so it's five at motion field yep two four five cool so in the idle push's position is going to be x is going to be zero y is going to be zero for walking forward y is going to be one and x is going to be zero for strafing to the side x is going to be minus one sorry strafing left and y is going to be zero for strafing right x is going to be one and y is going to be zero and for backward we're gonna have x zero and y minus one okay cool cool so as you can see this is theoretically our x and y parameters and it's basically interpolating between these um different motions right so now i i set them up on this 2d grid but now i have to assign each of these motion fields actual an actual motion so this is the um idle so that's just gonna add the idle um this one was the walking forward so walking [Music] this one was walking backward then we have strafe right and we have this sorry sorry this is walking backward yep my negative y is backward positive y is forward x negative is straight left and positive x is right shave okay so as you can see each of these animations is triggered differently you can actually check it out down here as well i'm just gonna press play so the person is walking forward when my two parameters are close to um x zero and y one right and going back to zero zero it stops and is in an idle position streaming left shaving right and walking backward cool that's pretty much all set potentially we have to change a bit these kind of parameters here to just make the animation react quicker and so on so forth but that's it for now actually already cool so what else is missing um we of course need to actually make the make a controller for the players to say if that makes any sense so we will create a player empty set that zero zero zero or actually sorry let's create a capsule zero zero zero because we can use the capsule as it's um um the collider for the player so i'm gonna turn off that mesh actually can remove these two components already seen okay that looks good and i'm gonna drag my export in here so yeah cool so the capsule is going to be called player that's good and obviously we need also a camera in there which is sort of representing our camera for the player right i just gonna have it like this third person um you can change it to eye level or whatever that camera right that's that's all fine um just remember to take away the audio listener because otherwise it's gonna throw a couple of errors or give warnings that this is not possible to audio listeners in the scene um okay cool so let's add a script called player controller i know there are a bunch of tutorials on this and i'm encouraging you to actually go through them let me show you um probably that one of the best ones i think is by brakies i hope that's how you actually call this guy um i think it's a first person movement and he's using um the inbuilt player controller from unity but still um yeah i'm happy like go ahead and go through this if you want but i just tried to keep this as simple as possible and just quickly write something myself [Music] so let's open up that player controller cool so we need a couple of things here first of all we need a public animator called anime then we need a private rigid body as well as a why is it lagging what's going on public layer mask layer mask as well as a public bowl which is checking if the character is grounded or not okay before i forget we need a rigid body on our object let's go back to unity player rigid body okay back to my script first things first i want to cage my rigid body okay great so i will create a fixed update actually fixed update and i will create a couple of different functions in here first one is going to be grounded and then we will have a jump as well as a move okay let's first create the jump function what we're doing here is basically if input dot get key down key code dot space and this dot grounded then this rigid body dot add force vector three dot up times four these are a couple of settings i tried around with for some time so change them to your liking force mode i'm setting different force mode to impulse okay so this is my jump else ah okay no i actually don't need an else that's that's all it okay cool next one is going to check for if the player is grounded and if it's actually able to jump so ground it if physics dot check spheres i'm creating a check sphere i think practice does that as well in this tutorial transform that position plus vector 3 dot down so basically i'm creating a sphere and an invisible sphere which which is trying to collide with objects and this is going to be placed basically at the feet of the character and if there is a collision it means that the character is grounded or standing on the ground and the jump is yeah a jump can be initialized so if this dot what how did i call its ground ground it sorry grounded equals to obviously to true and else is not grounded equals to false okay so the layer mask is basically helping me to restrict the things the checks fair is colliding with so i just wanted to check against the the ground okay so potentially we have to obviously create a layer as well for the ground so okay so this anim so here we're setting now the bool in the animation controller which is called jump to is.grounded okay oops cool so that parameter through the crown check is being sent to the animator controller or animation controller okay cool so actually last thing move so private right move nope that was not intended okay so first of all we need a vertical axis equals to input dot get axis vertical this is basically mapped to w and a float i can show you in a second horizontal axis equals to input dot get axis horizontal then we are creating a vector which is called movement equals to list.transform.forward times vertical axis plus this dot transform dot right times our horizontal axis horizontal and vertical these inputs can also be negative so it's fine to just take one um one direction forward and and right so i also want to normalize it because i don't want to restrict the character from moving faster so to say when it's walking sideways or diagonally and then i just gonna transform that position plus equal to movement times 0.04 that's also a value i figured out in combination with the actual animation i downloaded so you might want to tweak it [Music] so then this dot anim [Music] i have to set the float as well the two parameters we set in the animation controller that's a vertical and it's going obviously the vertical axis and set float horizontal comma horizontal oops horizontal axis okay great that's pretty much it for for this part um yep seems seems alright cool i go back first of all we can drag the export into the player animation controller okay the layer mask okay we have to create a layer which is going to be ground i have to assign it to the ground cool and here i can set this layer mask now to ground cool all right um so we're almost there we have to obviously also pull the player into this controller here no we don't have to do that okay so that's cool in our export prefab we are missing the controller which we have to pull in okay and so okay let's just maybe just quickly test it if this is fine so far okay something is happening it's for sure jumping not sure why that is but let's see okay so a couple of things happened here first of all in the rigid body we have to constrain this guy here so it doesn't fall over i want to show you also the project settings in the input manager you can see that horizontal and vertical are mapped different inputs already so for example the left and right key or a and d are mapped to horizontal movement and the vertical is up and down and s and w okay cool so let's try this for a second okay something is working but the s somehow is mapped or whatever to do the jumping motion let me check so in the settings i'm changing this to has exit time it should be good let me try somehow it's jumping have i changed or have i misplaced one of the actions idle walking left no that's all good so if jump is true it's going to the jump if jump is false that should be good for jump okay maybe i did something wrong here grounded okay of course we have to change and this is not possible so if there is a um collision right grounded is getting turned into true but i don't want that also to be the signal to actually jump so it should be the other way around right if if it's grounded um like don't jump and um yep i think that's that's better let's try okay trying to hit the okay that seems fine now all right cool so it looks like it's fine so far right i can actually walk but i cannot turn around or do anything so the last thing you have to do is to change to create a little camera script so i'm gonna use a script which is called camera controller okay so first things first i need a player controller in here player then a private float sensitivity as well as a bright float clamp angle it's going to be 58.85 degree and then a vertical rotation as well as a horizontal rotation i need my start and here i'm gonna initialize the rotation [Music] to place the transform dot local euler angles x and this dot horizontal rotation equals to transform.look of euler angles dot y all right so then i need a update which i will call a look function as well as just for the sake of visualizing this straw array and this the transform oops dot position comma this dot transform dot forward times two um and a color dot right okay so the only thing i have to create is the look function private void look load mass vertical equals to negative input dot get axis mouse y and then mouse horizontal equals to input but get x is x so i add that to the vertical rotation vertical times sensitivity times time dot delta time and the same thing for the horizontal rotation [Music] mouse horizontal times sensitivity times time dot delta time then the vertical rotation is getting clamped so it cannot exceed a specific um rotation particular vertical rotation comma negative this dot clamp angle and clamp angle sorry just to be clean here as well as here actually cool so transform is the transform dot local rotation equals to quaternion dot euler dot vertical rotation comma zero f comma zero f and this dot player dot transform dot rotation equals to quaternion dot euler 0f comma this dot horizontal rotation comma zero f okay that's pretty standard um and that should be good to go all right so the last thing you have to do is to reference the right things so we need a player in this camera here okay cool go back to the scene all right let's hit play so cool so this is our our player and our camera sensitivity is a bit too much in my for my understanding maybe it makes sense to make that actually actually public just gonna change it to 200 or something probably not enough now but anyway yeah it's fine okay so our character we can rotate our character of course if it's standing in on one spot nothing is really happening but you have now the tools pretty much to download another animation from miximo and add it to your to your animator um how to actually move around for example but it's fine for now or so our character is walking around i can strafe right i can shave left i can walk backward and even sideways so to save or diagonally backward yeah that's all cool all right that's pretty much that hope that is simple enough and straightforward enough thank you for watching see you next time
Info
Channel: Philipp Dominic Siedler
Views: 12,296
Rating: undefined out of 5
Keywords:
Id: I_mjYhwSsS8
Channel Id: undefined
Length: 34min 37sec (2077 seconds)
Published: Sat Mar 13 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.