Motion Symphony: Quick Start P2 - Motion Matching States

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi there and welcome to this quick start guide for motion matching in motion symphony we're going to leave off where we were in the last quick start guide so this is part two so if you haven't seen that one go back and have a look you will need to know all the information from that to continue on so what are we going to do this time we are going to add in a different locomotion speed or style so we have running but generally with locomotion we can walk maybe we want to crouch maybe the characters sometimes injured so how do we separate the states in motion matching so that we can control them because right now it's doing whatever it wants to do based on our input okay so let's just get right to it and the first way i'm going to show you how to do this is by literally making two motion data assets and having separate states in the animation blueprint now you can do it have them all in one so we can add walking to this one as well and then we use traits to switch between the different sets within the motion matching node however this can get really bloated if you're not careful and you're going to have really large motion data files so i recommend balancing combining traits and states traditional states to best suit your project but i'm going to show you states first so let's start off by creating a new motion data asset and i'm going to call this one tutorial motion data underscore walk and i'll rename the other one to underscore run and i'll just set it up as usual i'll set the motion config the same one we used for the running and also the same calibration i'm going to uncheck optimization and i'll just save this close it and reopen it so my character shows up i'm going to pick some animations and these are going to be all walk animations these walk animations are all available in the example project so please see that so i want start stops plants i don't want canned plants not for walking continue straight snake run axle d-cell and circle spiral that's good enough for a basic set i'll add all those animations and that looks pretty much ready to go i will pre-process there probably is a bit of do not use tagging i need to do but for now i'm not going to worry about it we just want to get things working first okay so there we have it now we need to set up our states in animation graph now we could go through and actually add in another state here so this could be run locomotion then walk locomotion then you could have all these transitions but considering like walking and running it's just locomotion in general we could keep it in the same state and use a blend by blend poses node so i'm going to do that for demonstration purposes it's really up to you how you do these things first things first let's create an enumeration so i'm going to go to blueprints enumeration and i'm going to call this e locomotion mode and i will have two modes we'll have run and we'll have walk okay and we could add other things later like crouch and and whatnot in my animation graph i'm going to go to locomotion and i'm going to say blend poses and then we're looking for e locomotion mode like we just added and i'm going to add in the run and the walk meant to promote so locomotion mode and i'll just plop that over there we'll plug the one we've already gotten to run i'm going to copy and paste this motion matching node i'm going to set the blend times between them to yeah 0.1 is fine in fact it it should actually be zero because we're using motion matching and we're using inertialization so we're going to set all the blend times to zero and the motion matching node itself will trigger a blend time on the inertialization we just want to change our motion data on this walk one to our actual walk motion data and that should be pretty much ready to go on the graph now the cool thing is because we're using inertialization and this blend poses node has a zero blend time it's going to switch instantly between these so we're not going to be running two motion matching nodes at once ever so that's really good because that's going to be you know double the performance cost if it was blending between them without inertialization and we can add more we can add a crouch and etc but you should be able to get the idea just here okay so let's go to our character now and set up those inputs so first we need to go to project settings and i'll go down to inputs and let's just create a button that we can press and hold to trigger walking you can do this anywhere you like but this is the way i'm doing it for the tutorial so i'm just going to call this walk and i'll make it left control and that will do just fine and in here let's create our events so my walk input event and i'm going to create a variable i'm going to call this locomotion mode and we'll make this of type e locomotion nodes it's just our enum and when we press we want to set it to walk and when we release we want to set it to run the only other thing we need to do is we need to change the speed of our trajectory generator because when we're walking obviously we're going slower the trajectory needs to be shorter so let's grab our trajectory generator and we'll set max speed and we'll do the same thing here so the max speed uh for walking for these particular animations around is around 200 and for running it's around 400. now keep in mind that when we're talking about max speed on the trajectory generator we're not saying the actual speed that the character is going it's more important that it's conforming to our animations when we're considering the trajectory generator because the trajectory generator doesn't actually move our character so in this case my animation root motion goes at about 200 centimeters per second for walking and about 400 centimeters per second for running so this should pretty much work now at least for the trajectory we haven't linked it up but i'll just show you the trajectory when i press ctrl you can see the trajectory gets smaller but we haven't switched over to the other motion matching node yet so it's obviously not working very well so let's do that i'll go back to my animation blueprint and in our event graph we can set the locomotion mode and we're going to basically get it from our character i think i have the character back here again and probably case this and make this nicer but it's just a tutorial so i get locomotion mode chuck that in there and that should all work pretty well now so let me hit play and if i hit control okay it's a little bit choppy but it is working for all intents and purposes we might actually need a bit of a blend or we might what we probably need to do is set up the acceleration and deceleration so let's do that next because i haven't tagged anything up and i think the running animation is is missing the deceleration so it's gonna just really pop quickly okay let's go back into our motion data and we'll go to our runwalk excel d cell and i'm going to add a tag track for do not use and in this case i'm going to tag out all the running section because this is the walking section i want only the ex i really only want the acceleration to the point where he's running well sorry this is the walking one so only i only want decelerations to walking so from here on so actually everything previous to this is do not use you might actually want to split up your animations in this case so you don't have so many so much do not use but basically the the decelerations is what we want whatever the transition is going to that's the motion data it goes in so this is going to walk so we want it in here let's see where that deceleration begins it's just about here okay and then we get to a normal walk and as soon as it's sort of normal we actually want to transition into our walk loop so i'll add another do not use tag there and that will go until the next deceleration which is all the way which is going to start okay just before that so about there that's gonna go all the way to there and once he's in his normal stride again well do not use the rest of it okay so that should be tagged up pretty well we need to add this to the run animation as well because we don't have excel d cell in our in our run i believe so i'll save this and i will also pre-process it keep in mind that there's probably a lot of other do not use tagging that you might want to do like there's a lot of animation in here and also the walk snakes um i might do this now but i'll skip through it it actually needs a fair bit of do not use tagging just like the other snakes so do not use and i'll skip ahead in the video so you don't have to watch me tag up every single little bit there we go that's all tagged up so i'll hit pre-process and we'll save this and we'll just add the axle d cell to our run as well so yep it's not there pick animation so excel d cell so it's the same animation but we're actually going to do the opposite tagging so i'll select it and we'll add use remember the naming of this is only cosmetic and this time we actually want the first parts so the whole second part of this so from basically from um so run and then so how it's walk to run so from about here that's all do not use we don't need this first part so walking we only want the acceleration part so from about there because we don't want to accidentally play a walking loop while we're motion matching and he probably gets into the stride fully there we don't want the turn in places at the end like so he stops and turns we don't want that and we just want this little section from about there so just before he starts to actually start to actually see the acceleration at that point so maybe about there that's where we want to keep okay and i've done this in previous tutorials cool we'll pre-process this save it and let's see how this looks so we're running walking running walking there's a bit something a little bit something going on there let's go into our animation graph and let's go to our blend poses and let's change the blend type to [Music] inertialization so transition type to initialization and let's actually give these a little bit of time i also want to double check my motion snapshot and we'll hit play there we go it's a little bit better you know what i think the problem is i think we don't have enough coverage so let's actually fix that i'm going to increase the coverage significantly by reducing the pose interval to 0.05 not 0.5 0.05 and i'm also going to add a mirroring profile so this is for the runtime mirroring now there's a mirroring profile that's set up for the ue4 skeleton that comes with the example project i'm not going to go into detail on how to create it there's another tutorial available for that so check that out basically it's a list of rules for mirroring a specific skeleton and on each animation that i want to mirror i'm going to just check enable mirroring and we can pre-press that process that and take a little bit longer because there's a lot more poses to generate and i'll save it and i'll do the same thing on the run this is going to give us a lot more poses and but also a lot more coverage and it should be a little bit smoother to counter the fact that we've got more poses we're going to look at optimization in the next tutorial so set my mirroring profile and again i'm going to enable mirroring on all of these animations in some cases you might have animations that you don't want to mirror maybe they're already like loops or something you probably don't want to mirror loops because you'll get different cycles in there anyway or if you have an unsymmetrical pose that you don't want to mirror in this case everything mirror is just fine pre-process that and we'll try this out again yeah it's working pretty decently okay you might actually be better off having a little bit of blend time after all or having it as different states let's try this just just for uh just for to see what it looks like we'll set those to 0.2 and set it to standard blend see if we get a smoother result yeah that's much better cool so now we have running and walking and that has been set up with two separate motion data assets let's now do the opposite and set it up all in one so let's go to animation graph and we can actually just get rid of this for now and we're going to just use the one motion matching node with the one motion data asset again and we need to add our animations to that but first we need to set up some traits so let's do that first in the project settings and we'll scroll down all the way to plugins and under motion symphony we'll see the section called traits and this is where we can name our traits there is a limit of 64 traits which should be enough and in this one i'm just going to call it walk we can close that now and we can now set up traits with that walk trait in our motion data asset now if you have other traits you just add them to that list so these are all run animations now i haven't added a run trait because i don't want to go and tag every single run animation up with run it's just going to be the default so no trait and i will add in the walk animations but these ones i will have to give a trait now i could put them in without the traits at all and we're going to test that out first and just see if the motion matching can handle it well it probably will handle it for the most part but you'll find that you'll want to have a lot more control over these things so you will continue yep all of those ones we've already got axle d cell and we'll have to change some tags on that okay so now we've added these animations let's just pre-process this as is and test how it does without any traits and only using the trajectory length being different to to match the different uh states so we're basically trusting the motion matching here to do what we want i'm just going to go into here and actually we don't need to go into that go to our character and all we need to do in this case because we're not using these anymore we only need to change the speed of the trajectory and we're hoping that the motion matching system goes ah okay let's use walking animations now because the trajectory matches better so i'm going to hit play and as we run if i hold ctrl it does get to walking but you saw with the deceleration there was a bit of funny business going on there and part of that is because we we tagged out the deceleration acceleration nodes so let's actually go back in there and in our run walk because remember we set this up for running this run walk so all of this is un is tagged as do not use so we actually want to revert that and make sure that we have access to the decelerations as well so bring that back to there there we go pre-process save as as i said before the motion data asset is getting clogged up with a lot of animations and a lot of poses and that's why it's taking longer to save so there is a limit to how much you want to shove into one pre-processed data and that's why i like to separate them sometimes but this is still okay let's hit play and we should get a better deceleration and an acceleration there we go that's actually doing really well considering we're just trusting the system let's give it a few more tests so let's try and make it so i'm gonna i'm just running here i'm gonna try and make it do a walk animation but without actually doing a walk animation and often this can happen by doing i'm crazy let me turn the trajectory back on i turned it off off screen so and a dot atom node dot mo synth trajectory debug two there we go yeah i actually can't it's done pretty well on its own now this might not always be the case so just be aware of that um and you are searching through a lot more poses so it probably is better to separate it by traits but yeah that's working pretty decently i will still separate by traits just uh for demonstration purposes so we know how to use traits because in some cases when it's like crouching the trajectory is not going to be enough because the trajectory might be exactly the same for crouch moving and walking and then you actually are going to have to separate it by traits so let's go into here and for all our walking animations we're going to add the walk trait now there's two ways we can do it we can add tags and whatever poses are within the tag are going to be marked with that trait however if the entire animation is going to have that trait then we can just add it in this little details panel we can add a trait name can add as many traits as we want but we only need walk so for each of these walking ones i'm going to go ahead and add one walk for each of those okay as i i previously missed i'm actually going to put the cost multiplier of this right walk straight neutral to 0.85 just like i did with the um the run um that just makes it more consistent for general walks okay so we've got walk now the only place where we will have to use tags for the traits is to run axle decel because half of this animation is running and half of it's walking so let's just add another tag track and i'm going to call this traits now remember we only have to tag up the walking ones so this is going to running and therefore it's not a walking one this is also going to running so we just need uh some tags here for traits and i'm actually just going to cover this whole section just to save time even though it's covering sections that i do not use because they do not use it doesn't matter if we tag it what it doesn't matter what we tag it really because it's it's a do not it's not going to be used so we can just type in here so once we select our um our tag we can edit it in inspector here and i'm just going to type in walk now remember these trait names they have to exactly match a trait name that we set up in our project settings otherwise it won't work so just keep that in mind so when we pre-process this this should now work pretty well except um it's not going to work straight away because we haven't set any traits i'll show you what i mean these animations aren't going to play so if i hit play if i hit control it it can't actually play those walk animations because i haven't told the system hey please use these traits so let's now set up the logic for that there's a few steps we've got to do so the the first step the easy step is setting it up on our motion matching node we need to expose traits so under the traits section we can either bind it to a variable or plug it into a variable i'm going to bind it let's just create a new variable and i'm going to call this motion it's a it's of type motion trait field now the cool thing with this is that in the single variable it because it's flags we can have as many traits set at once so it's basically a list of booleans saying true or false for all these different traits um but yeah if you know how flag fields work then that's exactly what it is it's a flag field with 64 options and we're going to set this i'm just going to call this uh current traits and i will now bind that to the required traits here okay so that is set up there um we do need to go to our character before we set it up in the event graph so on our character instead of having these enumerations anymore we're going to make another motion trade field here and i'll call again call those current traits and by default the current traits is going to be just nothing so i'm actually going to initialize this on begin play or clear traits i guess it's going to be cleared by default but i'm just calling this just in case so clear trade field and here we're going to get traits we're going to add trait now there's three different functions we can add trait by name now this is the one of the most inefficient ways to do it so we type and walk there we can also add traits well we can have a list of names that that's probably way more uh inefficient because the list of strings the most efficient way is to add trait field so if we have another variable we can basically cache our trait handles and then we can have another variable that is a motion trait field and we can say it's the walk trait and what we could do on begin is we could say okay walk trait and we go add add trait and we can use the string just that on begin play so we're not trying to search for that trait every frame and then we could actually just add the new trait and plug in our walk trait but just for the sake of simplicity for for this uh tutorial i'm just going to add it in the most basic way add the walktrade and then what we want to do is we want to remove the trait and we can remove traits in the exact same way as we add them it's just to remove instead of add and i'll type walk so this is effectively being our is walking boolean now or our um our enumeration so we're adding the trait when we are walking and we're removing it when we're not and here we just want to see we don't need this locomotion mode anymore instead we are going to take our character and we'll just get current traits and we'll set our current traits here and because that's already bound that should now work if i hit save and i hit play there we go it works now so now we've actually separated the data by traits and i would highly recommend doing this because the other way where we have them all without traits and it's just using the trajectory not only is it risky it might not pick the right animations but it's also less performant it's got a lot more poses to search through so you want to actually separate them and if you do separate it by traits it's only going to search the traits that you wanted to search we'll talk a little bit more about optimization in the next tutorial but there we go we've pretty much set up you know different locomotion speeds or locomotion modes if you were to do crouching or an injured character you do it exactly the same way as i've shown you for the difference between walking and running it's really up to you how you do it motion symphony is never meant to be know be all and end all like it takes over your whole animation system it's meant to be a bunch of tools that you you place in your different states and use them as needed so without further ado let's just end the video there and i will continue on with optimization in the next tutorial thank you for watching
Info
Channel: Animation Uprising
Views: 1,097
Rating: undefined out of 5
Keywords:
Id: n8qn2v0jfiI
Channel Id: undefined
Length: 27min 30sec (1650 seconds)
Published: Sun May 16 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.