Blender to Unity Shenanigans finally Working!


What a slog! What I thought was going to be a relatively simple workflow for getting animations from Blender to Unity working turned out to drag me down a rabbit hole that would consume a whole weeks worth of progress. Since this is a devlog I will try and delve into the details of how I got it working and what steps I am currently taking to mitigate some of the animation issues that will no doubt rear their head from time and again.

First, there is no straight easy way to get characters animated using a rigify rig or any rig for that matter directly into Unity as Unity doesn't pick up on the "control rig" that is used to drive the skeleton on the character in Blender. Unity only uses the bone deformation information to drive the animations and the current skeleton that rigify is using to drive the animations in Blender is not in a compatible format for Unity's "Humanoid" rig type. What? Let me explain further.

Unity has 3 rigtypes, Legacy, Generic and Humanoid. Legacy is the type of rig that Unity used before Mechanim which is what the current Humanoid rig type uses. Mechanim and the Humanoid rig is what allows the animations to be used across any other character in the game that is set to a humanoid rig. So if I have 10 characters in my game, I can share a walk cycle between all 10 of those characters regardless of their shape, size or look if they are using the Humanoid rig. This has major advantages in my case when I add more girls to the roster and you will want to share pickup/drop/walk/sit animations. The Generic rig basically means only this particular rig can use the animations and they cant be reused for other characters. I cant use a walk cycle from one generic character to another or to a humanoid rig.

So obviously, going with Humanoid has a major advantage over the other rig types, however Unity has a very specific way it want's its bones/skeleton setup for the character and that was the major issue between Blender and Unity as the way Blender's Rigify rig controller is setup is different than the setup that Unity wants for the Humanoid rig. I found a very convenient plugin called "Game Rig Tools" for Blender that re-targets the animations created using the rigify rig in Blender to a Game ready rig to import into Unity. This is not a straight forward process and required a lot of trial and error, document reading and tutorials.


Once this process was complete I could import the files into Unity and that's when I ran into the next set of hurdles. Turns out not everything in the gameready rig translates well into Unity, even though it's a "game ready rig!" After many more hours of 23 versions of the main character, I was able to get the her into the game playing her animations without jumping all over the place. I setup a few basic animations on the character and wrote a script to handle the parenting of objects in sync with the animation played. She can sit in an idle pose and pickup the wine glass, raise a glass to celebrate, put the glass back down. She can also Pickup the knife and put that down as well. I have segmented the animations to allow for separate events. For instance she cannot celebrate with a knife in her hand, but she can celebrate with a glass of wine, or later with a glass of champagne.



In this way, it should be easy enough to setup a branching selection of animations to play based on context. This is also a first pass and as the complexity increases I will need to probably organize it better, but with this current setup I can get about 90% there. Here are the animations in game: 
With the workflow finally set I will spend some more time creating animations for each of the objects on the table, at least on her side of the table and perhaps a few eating animations.
After that I will get to work integrating the branching dialogue/satisfaction system which will control the main gameloop.

Comments

Log in with itch.io to leave a comment.

Sheesh, something to look out for huh. I've had my own trials with Blender to Unity animations, and I've only done so like, three times.
In my case, I've always done Generic Rigs, ( Using my own Setup, not Rigify ), and baked the animations during the .fbx export to get the movement caused by the control rig saved as if the deform bones were being animated.

(+1)

Yes, generic rigs would work just fine. In my case since I want to introduce other characters eventually the rigs need to be humanoid so I can share animations and not have to redo them. In the case of this game that would be especially useful for picking up and putting down objects on the dinner table since each of the animations also have event triggers to trigger the picking up and placing down of objects in the scene.