Blender to Unity: Animated asset structure instantiati

I’m very new to Unity and only somewhat less new to Blender so I’m investing some time in familiarising myself with the workflow needed to get skinned, animated models into Unity.

I’ve succeeded in importing a non-animated, non-skinned model, and attached a MeshCollider and got interactivity working. The node hierarchy of the import was easy enough to understand; I created an interactive prefab and all worked hunky dory. See attached “monkeytest.blend”.

I’ve just built a new blender file “ExpressiveMonkey.blend” (also attached) to test a couple of basic animations for import. It has:

-One simple mesh of a monkey head.

-Two simple animations on the head mesh, one where the whole head nods (root bone), and one where the eyes (child of head/root bone) move from side to side. They are 2 separate Blender Actions – I’ve read this is now a working feature in the FBX Exporter. I haven’t tried to crossfade them, though presumably that ought to work if both animations work individually, which they do.

-A material, including it’s single texture. This skins the head and eyes, which are one mesh.

The problem in this case I don’t understand what it is I am looking at in terms of the imported hierarchy, or how I’m meant to instantiate it (or pieces of it) in order to make my own prefab. Do I instantiate from the root of the whole complex asset? I’m not sure that it is meant to be that messy inside. Try importing the file ExpressiveMonkey.blend to see what I mean.

When I instantiate the import as-is in the game world, I get this:

ExpressiveMonkey (transform with Animation component)
->Armature (transform)
–>ExpressiveMonkey (transform, otherwise empty)
–>Head (transform, Skinned Mesh Renderer)
—>Eyes (transform)

(…Perhaps someone can show me, using similar notation, what their animated import hierarchies usually look like, so I know if this is totally whacked out or not.)

One thing that caught my eye here was there is no Mesh Filter, so I can’t see how it would render, unless the Skinned Mesh Renderer created on import handles this aspect? Also there is a lot of separation into discrete nodes – only not where I want it. For example, “Head” in my hierarchy is actually a bone (and thus nothing more than a transform in Unity). However, it has combined the bone with the underlying mesh in this node(?), since that’s the node with the Skinned Mesh Renderer on it… :?

There is a substantial difference in how data is structured on import, between the first and second .blend files I’ve attached. And the second one’s got me confused as can be. Much of this may boil down to my ignorance of how things should be set up in Blender, so sorry if any of this sounds stupid.

Essentially, I want to know how to get things organised neatly so that I can work easily with assets, using script, once they arrive in Unity.

260515–9360–$myimports_207.zip (124 KB)

I’ve found importing all but the most basic skinned assets from Blender to Unity is a nightmare. I’m actually working on making this process less painful this week via Editor scripting. I’ll post the results here if you’re interested.

I opened your “expressive monkey” file, and the first problem I noticed is that you’re using an armature modifier. The exporting process for such a thing is so bad as to be unusable, in my experience, at least for Unity use. So first thing’s first, get rid of that, and use parenting to an armature, instead. It bugs me that you can’t animate “the right way”, but unless you have the time and ability to rewrite the .fbx exporter, it’s a bad idea to use that modifier. After you sort that out, let us know what other issues you have, or if that just fixes everything.

(The problem that occurs with an imported file using an Armature Modifier is not unlike what happens when you try to use Dupligroups, by the way. It’s just made more complicated by the skinning. Why anyone thought it was a good idea to duplicate assets outside of the hierarchy you create is beyond my comprehension.)

Hi Jessy

A number of your posts (along with Gustavo’s, Eric’s and Andee’s) have been instrumental in getting me this far – many thanks.

I’ve removed the armature modifier but I think it doesn’t relate to the problem I perceive myself as having (note that wording!). I think the problem (as I see it) is endemic to the way Unity imports .blend files? And perhaps this offends my aesthetic side.

The hierarchy after removal of the modifier and re-import remains:

ExpressiveMonkey2 (root of asset, transform + Animation component)
->Armature (transform)
–>ExpressiveMonkeyObject (transform; this is the object as in Blender’s Object Mode)
–>Head (transform + Skinned Mesh Renderer)
—>Eyes (transform)

So my question is, is this the kind of structure I should be expecting to receive into Unity? Or is it messy and will that cause me scripting hassles as a result? Do your animated asset imports usually look like this in terms of structure? And why is that ExpressiveMonkeyObject in there at all? Is it cruft? … When I delete it from the instance, the animation still works fine (haven’t checked yet whether it affects material mapping at all).

I noticed in a screenshot found in the Unity docs, that Lerpz has his name appear twice in his asset hierarchy – presumably one for the actual prefab/container itself, and one for the root object node from the 3D asset creation package in question. Just like my models. Perhaps this is normal, then.

If you do get a script working, that’ll be great. Perhaps it’ll get a special place…

260631--9364--$character_animation_2_853.jpg

Go ahead and upload the updated file, and then I’ll look at it while I follow along with this latest post of yours.

Here it is…

If you see any other general no-no’s in there that will help me get my assets structured neatly in unity, please call them out. I’m as new to the animation side of Blender as I am to Unity itself.

260671–9368–$expressivemonkey2_828.blend (305 KB)

Okay, sorry it took so long to check this out. We watched Requiem for a Dream. What a downer! :cry:

I’ve been trying to fix your issue for a while, but I’m sorry, I don’t know how – I haven’t encountered this problem yet. For whatever reason, your root bone is getting the Skinned Mesh Renderer, instead of the object that contains your mesh in Blender. What I’m used to seeing, would be ExpressiveMonkey getting the Skinned Mesh Renderer, with Head and Eyes just being a chain of transforms. Now, if all the vertices of your mesh are weighted 100% to the root bone, it doesn’t really matter, but I still don’t know how this happened.

As it is, yes. All you need is the chain of bones, a Skinned Mesh Renderer, and a parent that rotates 270 degrees in X (because Blender’s axis system is dumb and not configurable.) The parent also allows object-level placement, along with fixing the rotation. So the cruft is everything else. It can be good for organization, and if you delete it, you lose the link to the asset, but isn’t necessary for animation.

Right now, all you actually need is “Armature”, “Head”, and “Eyes”. But I think it would be beneficial to necessitate ExpressiveMonkey as well, for versatility and organization. Please let me know if you find out why this happened this way for you. Unparenting and reparenting doesn’t help, so I’m stumped. :?

Jessy, are you running Blender 2.49b and Unity 2.6?

I’m wondering particularly whether something has changed in how Blender organises things…

I’ll get back to you when I see any progress.

I am.

I don’t think so. It definitely has something to do with your project. I can’t get the root bone to get the Skinned Mesh Renderer with other files. But I honestly don’t know if it’s some kind of corruption, or if this is expected behavior under some circumstances.

Eureka.

First of all I want to clarify that there were 3 separate issues (to my eyes) here:

  1. Why the mesh was appearing under the armature node in only some .blend files? Obviously this simply reflects the structure of parenting set up in blender. So this will always be the case if you are not using an armature mod, as it’s the only other way to get vertices responding to bone motion.

  2. Why was there an extraneous node (with nothing but a transform on it) under the armature? Well, that was a result of no. 3 below, and is solved when that issue is solved.

  3. Why was the (skinned) mesh renderer appearing on the armature? Well, that’s easy. It’s because the armature had only one bone… it was just a test case, and a bad one at that! The minute you add more bones to that first bone, it all comes right. Is this a bug? Who knows. But I doubt anyone wants a single-boned skeleton, anyway… it’d be hard to get around.

Re no. 3 above, this issue comes into play only when you use the armature modifier approach, the instant you set the object reference on the arm. modifier to a single-boned armature. The minute you switch it to a multi-boned armature, or add an extra bone in the one it already points to, voila, your problems disappear. With that said, I see no problems with armature modifiers otherwise – from my testing today they seem to work in every instance that the parenting-to-armature approach does, and it looks cleaner on instantion as the parenting of mesh to armature is then unnecessary.

Armature modifiers seem to be supported just fine and they result in exactly the same animations as you’ll get if you simply remove the modifier and parent the mesh. Unless there are some things I don’t know about them?

Anyway, glad this particular long haul is at an end. Personally I’ll be sticking with the armature modifiers for the cleaner asset instances they produce, now that I know what’s going on.

Best,

Nick

That’s not true. You had two. A third bone does fix it, though. Weird!

(In other cases I just checked out, it is the second bone that moves the Skinned Mesh Renderer, not the third.)

What I want you to do, is move the armature object, in Blender, then look at the result in Unity. I find that to be completely unusable. Disagree?

Re there being 2 bones cough I thought I’d just breeze over that bit. But yeah as you saw, adding bones does seem to fix it somehow. Starting with a fresh .blend file that I know I can get working, is all I care about right now. ExpressiveMonkey can go take a flying jump :wink:

Re the latter… according to the Blender guys, you’re never supposed to move the armature object relative to the mesh-containing object, see http://wiki.blender.org/index.php/Doc:Tutorials/Animation/Armatures/BSoD/Preface:_Rigging_in_Blender:

“This means that both the mesh and the armature should be in the same exact location and, as always, they should both have 0 rotation and a scale of [1,1,1]. … As shown on the armature intro page, moving a mesh relative to the armature is a bad thing.”

Honestly I can’t see why you’d do that, but everyone works in a different way!

Nick, is it possible you did any other steps, than just adding more bones, to fix the Skinned Mesh Renderer placement? Because I’m having the same problem. Regardless of which parenting method I use (and I have four bones), I get the Renderer attached to the first bone.

If you happen to think of any other changes you might have done, it would be greatly appreciated. :slight_smile:

John C>
“For all your days, prepare, and meet them ever alike;
When you are the anvil, bear - when the hammer, strike.”