Given an imported mesh model with multiple animations, I have seen three different ways of structuring them for use in Unity, and don't know which is best.
The one I first ran into, was Animation Splitting, from the Manual page on Animations. It presumed that the model had one loong animation, which you split up by hand, telling Unity what frames made up each clip. I think I can rule this method out. :)
Method 2: I found while playing with Blender, is to use its Action Editor to create multiple Named Actions. When I imported the model into Unity, each Action became a playable Animation Clip.
Method 3: is of course using multiple model files, again from the Manual page. Each file has a single Animation, with the filename becoming the Animation clip name.
So: what are the consequences of using either of these two methods? In terms of ease-of-use in a script? In terms of project size?
I realize that Unity's documentation uses the multiple-file method, as does, for instance, their Character-Animation Tutorial, etc. Does that mean it's the recommended way, or just how their 3D modeller worked best?
Looking at their tutorial, I see that every file is at least a megabyte. It looks as if, every file includes a copy of the original mesh, which is a lot of duplication. For a project with lots of animations, wouldn't that be prohibitive? Would it be better (using Blender) to store all of the animations in one file, so there's only one copy of the basic mesh?
Are there any downsides to using the single-file, multiple Actions method? Will it be harder in the long run for me to use them, for any reason, in Unity?
In my previous project we used the first method you listed, however as edits were made frequently it became quite tedious to manually perform the splits every time, until we discovered the AssetPostprocessor Class in the Unity Editor Scripts.
By creating an editor script, you only have to list the splits in a script once, and if any edits are made you simply edit the script, which is simple seeing as they will generally be added to the end of the animation timeline in the asset file.
Here is the guts of the importer script, it isn't too complicated, and once setup an artist should be able to add the extra lines of code required once new animations are added to the single file.
Fill in the blanks, add your splits and away you go. Obviously you can get creative with it so if you have several models with the same animation line put them into a uniquely named folder and search for the folder name before splitting, making it easier across many files.
answered Mar 11 '10 at 01:54 PM
We use the "multiple file" approach, and have found that it works quite well for a few reasons. First, in Unity, you don't have to manually enter the splitting info or create any custom scripts. Second, in the modeling program, it is tedious to rearrange all the animations if, say, you find that your animation requires 30 frames rather than 20.
When you build a player, I think you will find that the only assets included in the build are the ones you use. So, if you have an "idle" version of the mesh that you are including in your scenes, as well as the animation files from multiple files, only the idle mesh and the animation files are included in the player - not duplicates of the same mesh.
answered Jun 04 '11 at 08:59 PM