Blender 2.82 - Rigify to Unity Tutorial - How to Export a Rigify Character and Import it into Unity

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys and welcome back to my channel my name is Stefan passion also known as infancia and in this video I'm gonna show you how I export rigify characters from blender into unity it's a few steps that you have to keep in mind I use a third-party script add-on for that one so I'll talk you through how to download and install that one and then how I prep the rig how I exported and imported into unity and whether you should use generic or humanoid rig i'll explain a few of the differences i'll finish up the video as well by doing some simple route motion to get their characters to propel forward with your animation and how I do that I'm also testing out a new noise reduction plug-in that I got from my friend let's call that let's see what it's called here it's called Bruce free by Cleveland it's a Swedish company that's made it it says that it's gonna remove any unwanted noise so let's enable it here and see if it works so let's click enable okay don't know if that works but let's keep it enabled anyway oh I got that plug-in for my good friend Lenny by the way thanks a lot for sharing that one he had a free giveaway so thanks for using that one hopefully it'll help me a lot in this video and save a lot of earache for my viewers in you so let's get started let's have some fun and let's do rigify to unity okay first of all we need to download the rigify to unity add-on so go to this github address and then just click on the clone or download and then download the zip file and once that's finished downloading you can just go to file well in blender go to file preferences Adams install and then you browse your way to your download location select the zip file and you'll see now that it's not actually appearing in the list and I had to do this I'm not sure if you have to as well but you start there the windows explorer and go to % update uh % and then follow this path that I described and then we need to rename this python file just click f2 and windows and rename it to underscore underscore init underscore underscore dot py and now it'll appear in the settings here so you can enable it and then close it okay now we're gonna fix the rigor so left click on the Reiki to select it and then go to the object data properties tab and click on the prepare rig for unity button that should be you might have to expand the reify to unity converter tab there first you should have a little message now saying unity ready rig at the bottom of your screen as well and then you select the characters that you want to ring usually it might only be one but I rigged multiple at the same time here so I select all of them and then I finished by selecting the rig lust and then I do control P armature deform with automatic weights and since I rigged multiple characters I hide all of them but one and then I just press play to see that the animation that I had before it is working and looking okay I'll switch to another character and then I also switch the action for that character and see that work also works and then I switched to that another character and here I can see that the Pirates has got a little bit of an issue here so if you need to assign vert these that are not following the rig make sure you now assign them to the any prefix bones with a d EF prefix which is a stands for deform and those are the ones that will be used in unity as well to deform your character so it's very important that you do assign them to the d EF prefix bonus and after doing that assigning those to the left hand it works pretty good and then you select all your characters and the rig I'm in blender here you go to file export FBX and then you browse to where you want to save them I usually save them into the assets folder of unity itself because unity will automatically import them then for you and you can also overwrite them in the future and automatically unity will import those FBX files so set the name make sure you have selected objects selected here so you don't get a lot of extra stuff with apply scalings set to FBX unit scale one meter in unity will be one meter in blender and under armature do only deform bones because you'll get a lot of extra unnecessary bones if you don't do that and then just click the export button switch over to unity and it'll automatically import it if you save it into the assets folder and select your objects and go to the rig tab and then you can see that there's a choice with the type here whether you should go generic or humanoid and that's something you'll have to decide and generic supports something called bone squash and stretch if you've used that so you can see that there left that one here is stretching the bones so that's the only one that supports that for me generic is about 20 to 25 percent faster but that's in my own tests I've heard the opposite as well so I'm not sure which one's true humanoid rigs on the other hand supports animation retargeting so if you have different sized characters they can share the same animation and humanoid also supports inverse kinematics like this aiming guy for example that's not supported with generic so if you need both squash and stretch then go generic and if you need retargeting or ik' or mirroring animation clips go with humanoid oh I want to issue a big warning as well if you do want to use bone squash and stretch in the engineer grid it will also rescale any objects that you have as a child or two for example hands so if you have a weapon in your hand it'll stretch and scale that object also if you have a hat on the head or a backpack that renders it pretty much unusable even though I to use the stretching I don't really want to live with the side-effects of having or objects in my hands rescaling and having to deal with that so I'll probably stick myself to using humanoid more even though I'd like to do the stretching okay so let's start with they're setting up a humanoid in the project folder click on the mesh and make sure on the rig that you switch the animation type 30 humanoid and then it'll be grayed out so you have to apply this first and then switch a tab and back and forth so you can come back into the screen otherwise you won't see the configure screen so once you come back you can click on configure and you have to save your scene if you haven't already because this will open up a new temporary scene that unity uses and here you can see if it mapped it correctly and usually it will do that if you follow the radii structure so here you can do some testing in the muscles and see it's a little bit dark here for some reason in unity but now you can use these little sliders here to see that the rig behaves pretty much as you were hoping so you can do some different actions here and it's only for testing as far as I know just make sure that it looks all right usually it's done a really good job and I've never really had to do any to be kinks or anything like that so I revert to the settings here and then I just switched out of there click on the done button and go back here okay it's not so much fun working with the great object so I collapse the project folder here and create a new folder called textures and I used my UV mapping technique so I'll drag my simple low pixel texture into the texture folder then I expand the mesh folder again and then it's time to drag this object into the scene and it'll look really dark as you can see and usually the lighting is a bit off so you can go to the lighting tab and do although generate for the lighting and I should light it up a little bit for you now we can go back to working with the material here so I create a new folder again and call this one materials keep it tidy and then right-clicking that one again and do create material and they can just fine name it common and I dragged the texture into the albedo map slide the smoothness down and I have to change this to no compression and dew point filter otherwise it'll get really blurry and if you look back on the texture now you can see that it's a nice and crisp if you use a low pixel texture like I have back in the hierarchy now we can expand the object and select one or more of our characters I select all of them and then I drag this common material into the material slot and that'll let put the same material onto all my characters I split the scene here so I have a scene view and a game view at the same time and then I create a new folder called it animator controller and now we have to create a new animator controller so we right-click on that new folder and you create an animator controller it's off my screen there because I use a high resolution and then we just call this one rig animator controller you can call it whatever you want and then double click on it to go in to edit it you're probably gonna have to configure quite a lot of States for your animation but for this one I'm just going to drag one of the wok animations in so I'll go to the project folder and select the mesh object that I've got and then I'll just drag one of the walks I'll do the new walk here and I'll drag that into the animator controller and that'll create a state automatically a default state and now we have to select the root object in the hierarchy and then assign this animator controller so just select that one and drag it into the controller slot of the animator and then we press play to test it out and I've got all the character so it looks a little bit strange but they did a little walk cycle there but it's not looping yet they look strange because I've got the five characters visible at the same time on the screen here keep that in mind so let's hide a few of them to get it less messy and here's the new doing the new walk now but again it just stops because we haven't set it to loop or anything like that yet it's a bit difficult to see when the character is floating in there how its behaving so I'll create a new box here and I just call it floor and put it to zero and the negative minus 0.5 on the y-axis and then I'll just rescale a little bit so a little pedestal for him to walk on this should be giving us a little bit better insight to if the feet are anchored to the floor good or not when you model your characters make sure that the origin of your mesh or the center of it is at the feet of the character okay now let's loop this animation so in the project folder select the imported FBX file and go to the animations tab and then click on the new block in this case and then do loop time and then apply that one and then we press play again and now we should automatically loop this walk cycle over and over again I don't know why but the unity is made it really tedious to set the loop cycle for all of the animations you have to do it individually you have to click on an animation click loop time and then click apply and then you have to go to the next animation and you have to redo it over again and if you have a lot of looped animations then it takes a lot of time to do this over and over again if you need to re-import your object later on you have to redo all this over and over again so I've actually created a little script to help me having not to do this all the time because it'll save me a lot of time and hopefully can save you a lot of time as well so I'll create the download link in the description where you can create the script like this I've prepared it and I won't have time to go through exactly how I programmed it all I can say that it's a hideous code so I create a new folder and it has to be named editor here otherwise it won't work and then in there I can if you download the script you can just place it in this one but I create a new one here called bulk and I'm setting and then I'll just copy and paste from another screen here so you but again you can download the script if you want it but I just paste it here and it just it's a little helper window that you can use to set this automatically for all your animations or add as many animations as you want I'll scroll through it here in case the download link doesn't work in ten years from now so you can pause it and edit it yourself type it in but hopefully the damaged link should work now there's a new window up there called infancia and I'll dock this to the side here and once it'll detect when you've selected an important FBX files and it'll just throw up a simple checkbox for all of those animations so instead of having to do that over and over again where you click on animation and do loop time and apply it you can just select all the check boxes and loop all of them if that's what you want to do if you want to loop all the cycles so you can just set the tick boxes that will do it all in one swoop so hopefully that could save you some time in the future and you can customize a script if you want okay now we can swap the animation so let's put the Peggy leggy walk on this guy instead and that's the guy with a peg leg and it works pretty good on this character because they all share the same properties and Riggin everything like and we'll switch their character out as well and that's what he looks like with his own walk here this would have actually worked with a generic rig as well because they're using the exact same rig they don't have any size differences so in this case it would have actually worked as well but we're still using a humanoid at the moment let's switch over to the police officer now and he's got a stretch walk for him he's used in the peg leg walk now but if we switch to his walk here in the animator controller let's change to the police or the calling the cop walks like a lair now we'll have an issue because that uses bone stretching in blender so if we I'll just rename this to bork because we'll use it for any walk here but you can see that he skips forward now he doesn't actually stretch the legs as the animation well so we'll do a little skip forward maybe that's what you want but probably it's not what you want this is one of the limitations now with the humanoid rigs it will not support stretchy legs and unity claims that it's due to performance reasons when you do the humanoid retargeting so that's a real shame it's it would have been lovely to have some stretching there but if we look here in blender now you can see that this cycle uses some cartoony leg stretching and he could have been for example something with really long arms or if you get hit by something so let's switch over to a generic we're pretty much done with the what we did for the humanoid rig there now go into the rig tab here and switch that one the animation type to generic and hit apply and that's really all you need to do if you press play now you can see that the bone stretching is working like we designed the walk cycle in blender to begin with that's really all there is to the generic class which simple as that but keep in mind those limitations that I mentioned before now we're actually going to switch to using route motion instead to propel the character forward I had animated all these characters to walk in place and usually I propel them forward with the script but we have to change a little bit now to make this character support route motion so let's apply this very scientific method here I'll go into the second keyframe here and then I'll put my finger at the tip of the of the foot and then I'll select all the bones and I'll just skip for all the frames and then I make sure that the tip of the toes is the tip of my finger so there is scientific here you could put an object in your blender scene but I'm too lazy for that so I'll just keep my finger on the screen and go through the keyframes and then slide a character forward so the tip of the toe is always at the same point and you have to switch feet as well because one foot is gonna go up in the air and it's easier to keep track of feet that are planted on the ground once you have done that for all your keyframe now you can see that the character is walking forward in the animation and it will snap back to begin back at the beginning and you have to use route motion for this to work if you don't do that and then all the Tector will behave the same in unity so we'll do the export process again how select everything like we did before and make sure we have this all the previous settings I'll reinforce it into unity here and as you can see all the loop time things have stopped back so I got my little helper script here to check all of them and apply all the loops back again here and that's really all those two that and now we can do some testing here and I made a duplicate of the animation walk cycle and called it route motion as a suffix here so let's switch the walk here to the new route motion animation that I created and then in the scene let's press play again now and you can see that the character walks forward as we designed it and then I'll snap back which we don't really want to happen it's because we haven't set it to do any route motion yet first let's make the floor a bit longer so it doesn't walk off the this little pedestal so I'll just stretch it out a little bit and then we'll do some route motion testing here in the hierarchy select your route object there and take the apply route motion under the animator and then we need to go into the FBX file here as well and then we have to set the root node so go to the rig tab and select the root node here and switch it from none and I actually forgot when I exported my object again I got a tremendous amount of extra bones here because I've got to select deform bones only and this is how many bones you get if you forget to select that it's about ten times more bones than you'd ever want and it impacts before I mean it's a real mess and it's pretty good that I showed that one anyway if you get that many bones then you know what to do go back and re-export your object and this time around make sure that you expand this little armature table at the bottom and then make sure you take this little only the form beause it'll save you into a much nicer hierarchy you can look now when you switch back into unity and really import this one now you'll see the big difference here if you remember what it looked like before and now you can see you've only got a small number of bones instead and now let's try again let's set the root node now and let's just set it to the rig / root / deaf spine bone and if we press play now it'll use the root motion that we've created and it'll automatically have your characters walk forward as intended with the animation that we created so this is how you enable root motion and you can also delete these little end bones you don't really need those as well but everything else is pretty much needed for the deformation but you can just delete those just unpack the prefab completely there if you want to be able to edit those and then you can create a new prefab if you want but again you can just delete those end bones if you don't need them alright guys I hope you enjoyed this video I hope it gave you a little bit of an insights how to get your rigify characters from blender into unity and if it did help you out please consider it give it a thumbs up and hit the subscribe button if you haven't already and check out my 10-minute yodeling videos no don't do that every Thursday I do a little 10 minute blender modeling video as well if you haven't seen those make sure you check my channel history and have a peek at those until next time have a good one stay safe have fun bye for now [Music]
Info
Channel: Imphenzia
Views: 236,501
Rating: undefined out of 5
Keywords: unity3d, blender, rigify, armature, rig, import, export, root motion, generic rig, humanoid rig, stretch, squash, stretch bone, generic vs humanoid, ik, walk cycle, tutorial, imphenzia, blender to unity, rigify to unity, blender 2.82, unity 2019, unity 2020
Id: vrN9duEoA6g
Channel Id: undefined
Length: 18min 20sec (1100 seconds)
Published: Mon Apr 27 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.