Well, Unity 2.0 had some issues with Blender importing (which I mentioned here). Since then Unity had a minor update.
I downloaded it installed it and…
:shock:
NOTHING WORKS!
I still have no animations from Blender! :x
The Unity page claims that it can import animations, and my own research has revealed that it is actually using the .fbx export script. (And I also demonstrated that the exporter works in Blender)
What I would like to know is is anyone else having this problem? (and also the correct grammar for that last line, I can’t figure it out)
And, more importantly, HOW DO I FIX IT!!!???
ANY suggestions would be greatly appreciated (because I’m out of ideas. I ran out of ideas a long time ago.)
Many thanks in advance.
Which version of Blender are you using? It has to be 2.45 at least.
2.42, 2.44, 2.45…
Tried it :roll:
File a bug, include the blender file you are trying to import. And make sure to provide an overview of what the issue is (Can’t import blender file)
If I recall, I’ve already done that as well. :roll:
I suppose I could submit one again…
And in case it wasn’t clear, I’ve already tried the obvious things. (I only claim the sky is falling after a chunk lands in my yard (and after I’ve already sold it on ebay for a lot of money because people still assume that chunks of sky are rare :lol: ))
“I’m out of ideas. I ran out of ideas a long time ago.” :?
Sigh…
54889–1996–$spinning_cube_160.blend (111 KB)
I opened your .blend in Blender 2.45, then exported it as a .FBX file and then imported it into Unity. It seems to work fine.
I’ve been recommending that people who use Blender use Blender’s exporter to save the file as a .FBX rather than letting Unity do it. I know it’s supposed to work the other way, but using my method I haven’t had any problems. Further, the Blender script is frequently updated, probably more often than there will be updates to Unity.
Lastly, be sure that you are using the internal exporter in Unity, not an external Python script.
HTH
54893–1997–$spinning_cube_160fbx_202.zip (4.89 KB)
Yes, isn’t that what I already said?
What difference does that make? Unity-BlenderToFBX.py: (most of it anyway)
import Blender
import sys
import os
try: import export_fbx
except:
print 'error: export_fbx.py not found.'
Blender.Quit()
# Find the blender output file
outfile = os.getenv("UNITY_BLENDER_EXPORTER_OUTPUT_FILE")
export_fbx.write(outfile,
EXP_OBS_SELECTED=False,
EXP_MESH=True,
EXP_MESH_APPLY_MOD=True,
EXP_MESH_HQ_NORMALS=True,
EXP_ARMATURE=True,
EXP_LAMP=True,
EXP_CAMERA=True,
EXP_EMPTY=True,
EXP_IMAGE_COPY=False,
ANIM_ENABLE=True,
ANIM_OPTIMIZE=False,
ANIM_ACTION_ALL=True,
GLOBAL_MATRIX = Blender.Mathutils.RotationMatrix( -90, 4, 'x' ),\
)
If I read the above code correctly, all this does is invoke Blender’s .fbx exporter. Updates to Unity have nothing to do with the actual exporter itself. This is one reason I’m confused, as Unity uses Blender’s own script. The script works, and Unity can read the result, so why can’t it import properly?
Umm… what? Isn’t the internal Unity script passed to Blender… so that would be an external script for Blender…? And isn’t manually invoking the exporter using a method other than Unity’s internal script…? And didn’t you just say that works…???
I think that last sentence needs rephrasing. The way I understand it, it makes no sense.
Next question: can you import the .blend itself properly?
Sorry, there’s a typo in my last sentence. Should read “be sure to use the internal exporter in BLENDER” (not Unity).
When I tried importing the .blend into Unity, all it imported was the cube, no animation. When I opened the .blend in Blender 2.45 it opened properly so I exported as .FBX. (although you had 30 frames of animation but the entire animation was 250 frames, so I trimmed it down to 30 frames before exporting).
I’m not going to get into how Unity or Blender should work. You’re welcome to discuss this with the devs of both applications. All I was trying to do was show you a workflow that works and my reasoning for using that workflow.
The .blend imports fine here, without animation. I would suspect importing this type of animation is not implemented… it’s not using armatures.
But work it out with UT.
-Jon
Yes, it does work. I suppose it is better than coughing up for a commercial app, and… er… great, my train of thought was totally derailed by an idea: folder actions. Make a script (or a script in a script) that is a folder action. Whenever a file is added, it checks it it is a .blend. If it is a .blend, it manually invokes the export script, saves the .fbx (in a different folder maybe?), and poof! everything works! Which makes me wonder if Unity’s script even works in the first place…
I’m off to test the script and the armatures. Be back in a bit with the results!
Well, it’s been a bit.
I haven’t tried armatures yet, but I did try the script.
I pulled it from Unity and (with a tweak for file paths) stuffed it into Blender. It worked, but had no animation.
Progress!
The script is at fault, and that’s easy to fix. So far, I think the problem is in the parameters passed to the exporter, but I have no idea what to give it. Also, the script above is good enough for debugging, as all I did was pull out some useless print commands (and they even printed worthless information, too). I can’t find much of a manual for how to call the exporter from scripts, but I found the source here: http://www.koders.com/python/fidA64891B5D79CEF3FC701C156FA1DCF6B4C21B907.aspx?s=mdef%3Asort. I’m not sure if that is the most recent version, or if it makes a difference, but it’s there.
Well, we (more of I, actually) are almost there! almost…
The current version of the Blender to fbx exporter was developed for getting character animations correctly inside Unity, and it works great. If you use object IPOS and NLA animation, as you do in your example, you cannot get more than one action. Just use bones and actions for your animations and you will get it.
Understandable, but I can’t get any.
I tried that, and it actually worked! Thanks!
Now all that’s left is to understand why the exporter works in Blender but doesn’t quite work right when Unity calls it seemingly in the same way.
Well, we can rest well knowing that Blender importing into Unity does work, if with a few quirks.
I DID IT!!!
It’s the “current action”/“all actions” option on the exporter. If “all actions” is selected (which Unity does) the exporter takes all the armature actions and segments them into different takes, regardless of the animation duration set by Blender. This seems to also drop the standard IPO keys. If it is set to “current action” it (from the Blender wiki) “Use actions currently applied to the armatures (use scene start/end frame)”
Sounds like it would nix the multiple takes, but preserve the IPO keys. So it’s a trade off it seems. Well, feels like this should be in the Import settings dialog, no?
If anyone wants to change it (if IPO keys are more important to you than auto-seperated actions), open /Applications/Unity/Unity.app/Contents/Tools/Unity-BlenderToFBX.py (Unitron works well for this) and change ANIM_ACTION_ALL=True
to ANIM_ACTION_ALL=False
and you should be all set. (I tested it, works fine).