Animations from blender going super weird

Hi,
So I’ve made a robot character for a third person game in blender - I’ve only made 2 animations so far, an idle animation and a run animation. They both look fine in blender. Here’s the problem - whether I import my robot into unity as a .blend file or a .fbx file, there’s some terrible problem which doesn’t exist in the other one. It’s really annoying. Like, there’s no way around it, something goes wrong no matter how i import it.

If I export my blender file as an fbx:
When I import it into unity, the animations are totally messed up. Basically, the run animation looks fine, but the idle animation is sortof… a combination of the two. The upper body does the idle animation - you can see the robot breathing and his scarf blowing in the wind, but his legs are frozen mid step from the run animation. He’s sort of floating with his legs stuck on one frame (not the first frame, like a random one in the middle somewhere) of the run animation, while the rest of him is just standing still breathing calmly, with his arms by his sides. It’s hilarious. but really annoying. This happens both in the preview window thing and in game if i try to get him to do this animation.

If I import my blender file directly:
I don’t know why this happens, but somehow the idle animation is like… changed slightly. For this animation he breaths in, out, in, out. Then it repeats. What’s weird is that when he’s about half way through each breath, he suddenly shakes, really weirdly. just slightly, but you can see his head go back, the forward, then back really quickly, like a jack in the box that’s been punched in the face. only far less extreme, and much faster. what’s even weirder is that it doesn’t happen the first time he breathes in. only when he breathes out and the second time he breathes in. I’ve gone back to blender to have a look and it’s definitely not happening there.

I think the strangest thing about all of this is that I can fix both of these problems by importing my mesh in the other format - it’s just so annoying that no matter how I import it, one of these things happens.

Here’s some possibly useful information:
-blender 2.71
-unity 4.3 free version
-importing armature type as “generic”
-mesh has no single root bone - there are three root bones. i thought that might be the cause of the fbx problem, so i made a single root bone and set it as the parent of the other three, but it didn’t solve anything.
-I’m using the NLA editor thing in blender
-animation compression is off in the import settings

Usually when I have a problem it’s because i’ve done a stupid, but i can’t think why this would happen… This has got to be one of the weirdest issues i’ve ever run into making a game, it kinda feels like there’s a problem with one of the two programs or something. I dunno, maybe not. But yeah, thanks for reading all this. If it’d help, i can send you a copy of the .blend/.fbx/.unitypackage or whatever of this stuff, just ask

Thanks,

James

In Blender,

Go to NLA Editor. Delete all entries. (Highlight them in the NLA editor and press X on the keyboard).

Go to Dope Sheet.

Use secondary dropdown to select Action editor.

Select the rig and highlight all bones. Make sure you are in Pose Mode. Select Idle animation and go to NLA editor to see a new track has been made. Go back to Dope sheet and do the same for Run.

Go back to Object mode.

Save and Export as FBX.

During export Select Armature, Mesh and Other boxes (using Shift-key), change ‘Forward’ from -Z to Z, Deselect Leaf Bones.

Export.