Tutorial
Heading
Apr 29, 2021

Export a GLTF/GLB with several animations

The clear and simple steps to export a GLTF model with various animations included

The mission

As we progress with new projects in Decentraland, we learn new techniques and utilize new software.

One of the tools we've been using extensively is Blender, as it facilitates seamless export of GLTF and GLB formats. We have previously discussed animation in Blender in other posts.

Here is a concise guide to exporting a GLTF model with multiple attached animations. This enables you to switch between animations within a GLTF viewer of your preference.

Resources

  • Blender 2.9
  • GLTF/GLB viewer

Stash animations

To create distinct animations in Blender, it's essential to understand the concept of actions: what they are, how to create them, how they function, and how to delete them.

An action in Blender is a tool used to record and encapsulate data. Similar to other elements in Blender, actions are data blocks. When you animate an object by altering its position with keyframes, the resulting animation is stored within an action. Consequently, you can generate numerous animations by creating multiple actions.

Each animation can be treated as a distinct action for a character or object. For instance, animations like running, idling, and shooting can be defined as separate actions.

To initiate the creation of a new action in Blender, you will need to modify one of the existing windows or create an entirely new one. To achieve this, follow these steps:

  1. Hover your cursor over one of the corners of a window until the cursor icon changes into a cross.
  2. Click and drag your cursor to establish the boundaries of a new window.

Cursor and position to create a new window

Next, to access the action menu, modify the content of the window to display the “Dope Sheet”. From there, you can navigate to the “Action Editor” by following these steps:

  1. Change the content of the window to display the “Dope Sheet”.
  2. Within the “Dope Sheet”, navigate to the “Action Editor”.

Dope Sheet Action Editor. Changing the window to dope sheet

Dope Sheet Action Editor. Menu to change to the Action Editor

Once you have the editor in view, you can begin creating actions. However, before doing so, there are a couple of key considerations:

  • Actions can only be linked to ONE object. If your model is divided into two separate pieces, you cannot assign the same action to both of them.
  • To work around the above point, actions should be linked to the Armature. In Blender, an armature functions as a sort of empty group that serves as the parent for the model and its bones.
  • As the term suggests, an armature is closely related to bones. When you create an Armature, it automatically generates a bone, and they are intrinsically linked. Consequently, when you animate the Armature, the bones are affected as well.
  • Importantly, this means that models must be animated using bones.

Once you have created an armature (located in the top corner under Add → Armature), you are prepared to generate actions. With the Armature selected, click the "New" button, rename the animation, and remember to click the "shield" icon (If you neglect to click the shield, Blender won't save the new name, potentially resulting in the loss of changes made to the action).

Armature new action

With the armature selected create a new action.

When you have completed working on an action, close it by clicking the X button on the right side. This will take you back to the initial menu in the editor, allowing you to create a new action from the beginning. Here's an important note: if you wish to delete an action because you find it unnecessary, don't need it, or if you accidentally duplicated it, DO NOT solely click the X button (as mentioned earlier, this closes the action but doesn't delete it). Also, DO NOT press the delete key or the backspace key; these won't delete the action either.

The ONLY way to delete an action is to press Shift + the X button on the right.

After doing so, close and reopen the file to refresh the system. If you don't close the program, you might still see the actions that you've deleted.

Save the name and the action

Check the shield to save the name and the action.

Save the name and the action

Check the shield to save the name and the action.

Once you've completed all the desired actions, you need to store them within the model so they can be selected in the GLTF model. To achieve this, follow these steps:

  1. In the “Action Editor”, locate the "Stash" button on the left side.
  2. Press the "Stash" button to store the actions. Ensure that you don't intend to make further edits before stashing.
  3. Save both the name of the action and the action itself.

Menu with different actions

From Maya to Blender

Let's consider a scenario where you want to work in another software like Maya. The transition is relatively straightforward, but it involves a series of steps to ensure a smooth process. Follow these guidelines:

  1. Create the animations using bones. When you import them into Blender, an Armature will be generated.
  2. Ensure that all animations are on the same timeline, even if you separate the frames to distinguish animations. Keep them within the same timeline.
  3. Export the animations in FBX format with bones. In the export options, select "Bake Animation."

Once you import the FBX file back into Blender, it will create an Armature in the scene containing the animations. At this point, you need to:

  1. Rename the action to reflect the animation's content.
  2. Duplicate the action for each animation you created.
  3. Remove unnecessary frames and adjust the timeline to start at the appropriate point for each animation.
  4. After these adjustments, stash the animations and export the model.

This process will ensure that your animations are successfully integrated into Blender for further use.

Exporting and viewing

When exporting the model, ensure that you check certain options in the presets:

  • "Limit to Selected Objects": If your scene contains multiple objects, make sure you select everything inside the armature that you intend to export.
  • "Apply Modifiers": This option applies the deformation of the bones to the models.
  • In the "Animation" section, under "Skinning," select "Include All Bone Influences" to ensure that all the bones are exported with their influences.

After exporting, you can inspect the model's correctness using a GLTF/GLB viewer. There are several online viewers available. When you import the model into a viewer, ensure that there's a tab where you can select and preview different animations associated with the model.

This step will help you confirm that the exported model and its animations are working as intended.

Exporting and viewing

GLTF/GLB viewer
Art
Blender
Maya
Laura Usón
Creative Art Director

Passionate about videogames, movies and creatures. Artist by day and superhero at night.

Tutorial
Visual effects in Decentraland - A guide to create VFX without tools
Tutorial
Turning a 2D image into 3D using Blender
Tutorial
Trim textures: a new hope