# Export actions(animations) to FBX and open in Unity

I have a Problem with animating objects in Blender.

When I add the constraint "Follow_Path" to my objects and then bake animation, I have about seven additional Actions for one object.

The animation works very nice, but when I open the FBX format in Unity, I get all these actions and only one is the right one. For example Action.007

Mabye, I do something wrong with the selection?

Actions in Unity:

Here some Code:

def followPath():
for object in scene.objects:
scene.objects.active = object
object.select = True
# Settings
forward_axis = getForwardAxis(path)#I get the path from another function
up_axis = getUpAxis(path)
constraint.target = bpy.data.objects[path.name]
constraint.forward_axis = forward_axis
constraint.up_axis = up_axis
# animate the path
bakeAnimation()
object.select = False

def bakeAnimation():
bpy.ops.nla.bake(frame_start=1, frame_end=250, only_selected=True,
visual_keying=True, clear_constraints=True, clear_parents = True, bake_types={'OBJECT'})

• Can you post more of your script. Eg what is bakeAnimation(). Suggest using constraint = obj.constraints.new(type='FOLLOW_PATH') – batFINGER Aug 15 '17 at 5:44
• Nothing changes with your suggestions. My main question is, why are there so many actions, while I only made one per object? – matt Aug 21 '17 at 6:54
• did you check the action editor to see if they are there as well? You can try delete them from there. – SVAFnemesis Aug 21 '17 at 8:42
• Thank you so much! That was not exactly the solution but I have it now. – matt Aug 21 '17 at 11:06

The first problem is, that I don't clear the old actions when I start the script twice. Therefore, it appends the new actions to the old ones. Now in Blender there are only the needed actions.

However, when I Export it to FBX and open it in Unity I have the same problem.

You have to push the action down to a new strip: Open the NLA-Editor and push that button next to your action.

For the export you have to select the following:

When you open your FBX in Unity there is only one action for each object.

How you do it in python:

#Add NLA-Strip
bpy.context.area.type = "NLA_EDITOR"