- Home /
FBX blender animation file not working properly
I have read a lot of threads in the forum which relates to issues associated with importing FBX files created in Blender into Unity. However, none of those threads addresses my particular issue and I am pretty sure it is a simple solution / setting that I have missed.
My animation consists of a simple cube which crumbles into multiple pieces using the cell fracture in Blender. In effect, I have two cubes in blender: a solid cube (cube A) and a cube made of multiple pieces which crumbles as it gets affected by gravity (cube B).
My animation comprises 90 frames in total and works as follows: Frame 0 to 29: only cube A is displayed and rendered. Cube B is hidden and not displayed. Frame 30 to 90: cube A is hidden and not rendered. Cube B is displayed and rendered. This was done by inserting a keyframe in frame 30 in Blender.
The animation works perfectly in Blender. However, when exported into Unity, when the animation plays, both cubes (A & B) are always rendered. I have also tried to import the blend file into unity but I still have the same problem. I know it would probably be possible to achieve the same animation as in blender by script (i.e. making cube A inactive at frame 30 and cube b active from frame 30 onwards). The problem is that cube B is made of 200 different smaller objects so looping through each of those to make them active/ inactive would greatly affect performance.
Is there a setting I have missed when exporting from Blender? Any suggestions / help would be greatly appreciated.
Answer by Entairex1 · Sep 26, 2013 at 05:43 PM
1# Make sure you're exporting with animations properly
2# In Unity, you'd have to change animation type to LEGACY, do this by
Select animated object prefab => Click "Rig" in the inspector => change "Animation Type" from Generic to LEGACY
3# How did you make the cube "not render" in blender? by material, or by sizing it to 0?
(Sizing the cube to 0 in the animation would probably be the best solution)
Answer by LAustralien · Sep 27, 2013 at 02:01 PM
Thanks for your prompt follow up. Using the same numbering as above.
"1# Make sure you're exporting with animations properly" I think this part is fine as i) I can see my animation in unity when I select the fbx file in the Project Asset and ii) I can preview the animation in the inspector window.
"2# Change animation type to LEGACY" That is an interesting one. When imported from Blender, the animation type is "Generic" by default and, as mentioned above, I can preview the animation just fine in the inspector window. However, if I select LEGACY as suggested and "Store in Root (new)" under the "Generation" pull down menu and click Apply, then my animation no longer works in preview in the inspector window for the FBX file (i.e. nothing happens when clicking play).
"3# How did you make the cube "not render" in Blender?" In Blender, in the "Outliner" window, I deselected the viewport visibility (i.e. clicked on the eye icon so that it looks closed) and set the rendering property to "false" (by deselecting the camera icon). Note that given Cube B is made of a lot of smaller objects, I used the following python script to achieve the above (note I found the script in the following Blender tutorial http://www.youtube.com/watch?v=B8S_jU6iNCQ&list=UUiqJdL1lpnQ6Ng2xyFgMMIQ)
import bpy;
for object in bpy.context.selected_objects:
object.hide = False;
object.hide_render = False;
object.keyframe_insert(data_path="hide");
object.keyframe_insert(data_path="hide_render");
By the way, the video shows the very same animation principles I am trying to achieve from 9:00 to 9:20 and 8:00 to 9:00 shows how to do it in Blender. The script part is shown around 18:00 in the video.
(Sizing the cube to 0 in the animation would probably be the best solution)
The animation is not working properly because you're animating blender-specific settings. Unity and Blender don't share properties, so the solution is to simply scale the objects you don't want to be seen to 0.
This solution actually isn't a bad one. Example: In Team Fortress 2, they do decapitation by sizing the head down to 0 and spawning a new separate head.
Thanks Entairex.
I did try to scale down to 0 to make the cube disappear at the right frame and it worked. The only thing is that there is a little 'flicker' in the animation when the cube is being scaled down (I scale it from 1 to 0 between frames 29 and 30). Clearly I can't see such 'flickering' in TF2 so I guess I just need to tweak my animation settings until I get the right outcome.
A possible fix for that is to open up Graph Editor in blender, select the cube sizing section, press T => Constant
Your answer
Follow this Question
Related Questions
Unity Rotation In Animation Goes In Opposite Direction 2 Answers
Blender To Unity Animation Import Problems 1 Answer
Importing Keyframe Animation (not Bone-based Animation) 0 Answers
Animations from Blender jerky/skipping frames 1 Answer
Unity Import automatically adds unnecessary Keyframes 2 Answers