3
$\begingroup$

I'm fairly new to gltf and am gradually learning about it's abilities/limitations. I am currently trying to test a file that would have multiple objects animate in a scene. However, whenever I export, only one of the objects animates (but if I export them individually, they animate fine on their own).

I read in the documentation that "glTF allows multiple animations per file, with animations targeted to particular objects at time of export. To ensure that an animation is included, either (a) make it the active Action on the object, (b) create a single-strip NLA track, or (c) stash the action." but it's hard to tell if that means one object can animate multiple times, or if you can have multiple objects animate in the one export. As I tested this with no success, but maybe I'm not creating the NLA track properly.

Any help or clarification with this would be extremely appreciated!

Thanks :)

$\endgroup$

2 Answers 2

3
$\begingroup$

A newer manual says:

"An NLA Strip animation consists of multiple actions on multiple objects that should play together. To create an NLA strip animation with the name “My Animation”, push the action that should play each object onto an NLA track for that object with the name “My Animation”.

NLA Strip animations will be exported if the Animation ‣ NLA Strips option is selected (on by default). All glTF animations are imported as NLA Strip animations."

Or see here: https://github.com/KhronosGroup/glTF-Blender-IO/issues/219#issuecomment-453621051

The second part of that post: "If you have two NLA tracks with the same names on different objects, you should get a single merged animation out that affects both."

So you have to create NLA tracks and give them the same name. It worked with my animation. good luck with yours!

$\endgroup$
1
  • 1
    $\begingroup$ Amen to this! I was wasting time trying to combine all my animations into a single NLA action, thinking that was the solution. In fact, it doesn't matter how many tracks or strips you have - just make sure that every track you want involved in a single GLTF animation has the same name. $\endgroup$ Commented Oct 9, 2020 at 11:34
1
$\begingroup$

to export multiple animated objects with armatures, vertex groups should have unique names. here's a little script to rename bones and vertex groups based on parent armature name:

import bpy

for obj in bpy.context.selected_objects:
    if obj.type == "ARMATURE":
        prefix = obj.name + "_"
        for bone in obj.data.bones:
            bone.name = prefix + bone.name
        
    if obj.type == "MESH":
        prefix = obj.parent.name + "_"
        for vg in obj.vertex_groups:
            if vg.name[0:len(prefix)] != prefix:
                vg.name = prefix + vg.name
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .