Marrow Open Marrow

Guides

How to use an animated GLB character in Godot 4

By bxzex · · Updated

Godot 4 treats glTF as its main 3D format. A rigged .glb from Marrow drops straight in with its skeleton and every animation in an AnimationPlayer.

How to use an animated GLB character in Godot 4: a character rigged and animated in Marrow

Import

  1. Unzip your Marrow download and copy the .glb into your project folder. Godot imports it on its own.
  2. Drag the .glb from the FileSystem dock into your scene, or right-click it and choose New Inherited Scene to build a character scene on top of it.
  3. Open the AnimationPlayer node inside it. Every animation you downloaded is listed, named after it.

Make walks and idles loop

  1. Double-click the .glb in the FileSystem dock to open Advanced Import Settings.
  2. Select an animation in the tree and set Loop Mode to Linear.
  3. Press Reimport. Repeat for each looping animation.

Play animations from code

extends CharacterBody3D

@onready var anim: AnimationPlayer = $Character/AnimationPlayer

func _physics_process(delta):
    if velocity.length() > 0.1:
        anim.play("Walk", 0.2)  # 0.2 s blend from the last animation
    else:
        anim.play("Idle", 0.2)

Use the exact names from the AnimationPlayer list. For more than a couple of animations, an AnimationTree with a state machine or a blend space keeps the code short.

Moving the character

Godot character controllers usually move the body in code, so download walks and runs with In place on in Marrow. If you want the animation to drive movement instead, keep the travel and use root motion on the AnimationTree. See root motion or in place.

Blend between idle, walk and run

For smooth changes of speed, add an AnimationTree next to the AnimationPlayer:

  1. Set the tree’s Anim Player to the AnimationPlayer inside your character, and its Tree Root to a new AnimationNodeBlendSpace1D.
  2. Add three points: Idle at 0, Walk at 2 and Run at 5.
  3. Turn on Active, then set the blend position from your script:
@onready var tree: AnimationTree = $AnimationTree

func _physics_process(delta):
    var speed := Vector2(velocity.x, velocity.z).length()
    tree.set("parameters/blend_position", speed)

If you later need attacks and jumps too, make the root an AnimationNodeStateMachine and put the blend space inside it as one state. The path then starts with that state’s name.

Put a sword in the hand

Select the Skeleton3D node, add a BoneAttachment3D as its child and choose the bone RightHand. Anything you put under that node follows the hand in every animation.

Common problems

Questions

Does this work in Godot 3?

Godot 3 also imports .glb files, but the import window and AnimationTree look different from the steps here.

Can I share one animation library between characters?

Yes. In Advanced Import Settings you can save animations to files, then load them as a library in another character’s AnimationPlayer. Characters rigged from scratch in Marrow share bone names, which makes this work.

Open Marrow