Skip to content

Lack of Experience is Incredibly Frustrating

Today I wanted to work on making the Caravan Master npc more unique than the general Crew. The Caravan Master will allow the Player to halt the caravan for a short duration. For the world lore, the Caravan Master would probably be a "Clerk", which are denoted by an orange half-cape on their waist.

I got to modelling that but I wanted to do a quick version just to make sure that it would work how I was hoping. Spoiler: It did not...not at all!

Screenshot of the Caravan Master cape in progress

I was pretty happy with how it turned out for now. I got it weight painted and rigged on the same armature as the character mesh. Everything was working well in Blender. Once I tried to getting it out of Blender things started falling apart.

Extra Root Bone

The first problem I ran into was an armature mis-match when trying to configure the FBX after importing it in Unity. I wanted to apply the existing animation "avatar" to it that was created from the character mesh, since it should be the exact same rig. When I tried to apply it though, it said:

Rig Error: Copied Avatar Rig Configuration mis-match Transform hierarchy does not match Transform 'Armature' not found in: HumanDescription

This led me down a rabbit hole trying to figure out why the rigs were different, when I had imported the exact same character FBX into Blender before modelling the cape. One difference that I knew is that the original character was rigged and exported from Mixamo and I was exporting from Blender.

In the image below the Mixamo structure was what Unity was expecting but the Blender one had the Armature container at the root, instead of the mixamorig:Hips bone.

Screenshot of the Unity hierarchy showing the difference between the Mixamo and Blender exports

I wasn't really sure what was going on, because Terra had exported the goat without any issues and I had successfully exported/imported another character previously. I found forum posts from all the way back in 2014 asking about this problem. It appears that it really only shows up if you import characters rigged in Mixamo back into Blender, then go to re-export them. I tried a couple of the suggestions in the posts but none seemed to fix the problem. No matter what I tried, what settings I used, or script changes I made, that darn Armature container was always there...mocking me...

It didn't help that most of the posts I could find were for older versions of Blender and I think some things had changed. I finally stumbled upon A-Ribiero's CustomBlenderFBXExporter Blender Add-On that supposedly fixed the issue. I was hesitant because, again, the forum post was older. However, looking at the GitHub for it, it looked like it is actively kept up to date with new Blender versions.

I got that add-on installed and was pleasantly surprised that it added the functionality in addition to the built in exporters instead of replacing them. I thought this was very considerate and made me feel better about using it.

Screenshot of the CustomBlenderFBXExporter menu option

What really made me enjoy using it was the fact that it actually worked! Once I got the settings down (I was just missing the Armature FBXNode Type being set to RemoveGhost) I was able to export it from Blender and import it into Unity without any issues.

Screenshot of the CustomBlenderFBXExporter export settings

I'm not sure why this had to be as hard as it was. I spent several hours bashing my head against the wall trying to get it to work. I am still very new to rigging, animating, exporting, importing, basically all of the pieces of getting characters and such into Unity.

Side Quest to Texture the Cape

Once I could get it into Unity, I wanted to relax some and decided to texture the cape. I've textured multiple things in Substance Painter so far, so surely this should be easy-peasy. Right?

Well, my problems with texturing the cape seem to stem from Mixamo once again. They do something with the rotation of the model. Realistically, it is probably because Unity is weird with the Y-axis being up and they are rotating it correctly...but still! Well, in order for the rotation of the cape to match the character (or more specifically, the rig) I needed to rotate the object in Blender. Well, when I brought in the fbx to Substance Painter, of course it was sideways. This made rotating the object in its "actual" orientation very difficult. In the gif below, it should be rotating horizontally but because the cape is actually sideways in the viewport it doesn't.

Gif of the cape rotating strangely in Substance Painter

I think it also affected how the Metal Edge Wear generator applied itself to the mesh. I think it likes to put more grunge on upward facing edges, which unfortunately was the inside of the cape. Not my best work but at this point I was taking anything I could get!

Getting the Cape To Deform

Now, something that I had no idea how to do (even now) is how to add the fbx prefab to the existing Caravan Master prefab and have it use the same animations as the character. I thought, since they were rigged the same and this wasn't an uncommon thing to do (is it?) then there should be lots of resources on it. Maybe it was because it was the end of the night but I was just not finding anything. Most of the stuff I could find was adding to the rig in Blender and exporting the whole thing. For instance, if a character model had some armor pieces as separate meshes to make animating better, they would still export all of the meshes as one FBX.

A lot of posts that I found talked about a Bones array on the SkinnedMeshRenderer that needed to be replaced with the bones from the character but I couldn't find it. It turns out that the array is not actually accessible through the Inspector and I would need to write a script to handle it. It was getting close to bedtime and I didn't want to deal with trying to figure out the script for it.

Instead, I decided to add an animator onto the cape prefab and use the same Animator Controller as the character, then adjust the main CaravanMaster script to take an array of Animators instead of just the one. Then when it changed values (set bools, floats, triggers, etc) it would do the same on all of them. This actually worked. It was real nasty, but it was working! Well, only some of the time. To prevent all of the Crew from walking in lockstep, I had added a random offset to the animations. Since the character Animator and the cape Animator were separate, this meant that each Animator got their own offsets. Sometimes the offsets were more in-sync and other times they weren't. I thought I was being clever but once again my work was in vain.

Finally, I gave up on the whole cape thing and just added a dumb flag that the Caravan Master carries. Attached it to the bone and it was serviceable!

Screenshot of the Caravan Master in game with the placeholder flag

Right before bed, I did have an idea to look at cloth physics in Unity itself, so I'd like to explore that some more this weekend before admitting defeat and using the flag. Overall, one of the most frustrating nights of development I've ever had and I'm sure if I knew more about all of it, I would have been able to make sense of everything much quicker!