Marrow Open Marrow

Guides

How to use a rigged GLB with animations in Unity

By bxzex · · Updated

Unity does not open .glb files out of the box, but Unity's own glTFast package does. There are two routes: import the .glb straight in, or convert it to FBX in Blender for Unity's Humanoid retargeting.

How to use a rigged GLB with animations in Unity: a character rigged and animated in Marrow

Route 1: import the .glb with glTFast

  1. Open Window, Package Manager, choose the Unity Registry and install Unity glTFast. In older Unity versions, use Add package by name with com.unity.cloud.gltfast.
  2. Drag the .glb from your Marrow download into the Project window.
  3. Select the file. In the Inspector, set Animation Method to Mecanim and press Apply.
  4. Drag the imported model into the scene. Each animation you downloaded is an animation clip inside the asset, named after it.
  5. Create an Animator Controller, drag the clips into it as states, and assign the controller to the character's Animator.

This gives you a Generic rig. Clips play on this character exactly as they looked in Marrow. If you only need the character's own animations, this route is the quickest.

Route 2: FBX and the Humanoid rig

Unity's Humanoid rig lets you share animations between different characters and use Mecanim features like foot IK. Humanoid needs FBX.

  1. Import the .glb into Blender and export an FBX with every action. The steps are in the Blender guide.
  2. Drag the FBX into Unity, select it and open the Rig tab. Set Animation Type to Humanoid and press Apply.
  3. Press Configure to check the bone mapping. Marrow's bones are named Hips, Spine, Chest, UpperChest, Neck, Head, LeftUpperArm, LeftLowerArm, LeftHand and so on, which Unity maps on its own.
  4. On the Animation tab, tick Loop Time for walks, runs and idles.

Walking in place or moving forward

If your character controller moves the character, download the walks and runs with In place turned on in Marrow. If you want the animation to move the character, use root motion. Root motion or in place explains the difference.

Smaller files

Download only the animations you use. Every take adds keyframes for every bone at 30 frames per second, so a pack of 40 animations is much bigger than a pack of 5.

A first Animator Controller

Most player characters start with the same three states. With an idle, a walk and a run in your pack:

  1. Add a float parameter called Speed to the Animator Controller.
  2. Right-click in the graph and choose Create State, From New Blend Tree. Open it and set its parameter to Speed.
  3. Add the three clips with thresholds 0, 2 and 5, which are typical speeds in metres per second.
  4. In your script, set the parameter each frame: animator.SetFloat("Speed", velocity.magnitude, 0.1f, Time.deltaTime). The 0.1 smooths the change.

Attacks and jumps go in as separate states with a trigger parameter, and a transition back to the blend tree when they end.

Common problems

Questions

Which route should a beginner take?

Route 1. It has fewer steps and the animations look exactly as they did in the browser. Move to Humanoid when you want to share clips between characters with different skeletons.

Does this work with a mobile or WebGL build?

Yes. The imported character is a normal skinned mesh. Keep the number of clips and the texture sizes small for those platforms.

Open Marrow