Cocoa Nib Forge

Fusing art and programming

Automating Animation Retargeting in Blender After Mesh Modifications

So, you’ve found a character asset that comes with a set of animations. There’s just one problem. You want to modify the mesh.

The Problem

Modifying a character mesh often breaks the bone hierarchy or influences, wrecking the existing animations. If you’re dealing with multiple characters based on one rig, redoing each animation manually is a massive time sink.

The Workaround: Animation via Empties

You can preserve animation control by offloading bone motion to empties. Whatever shape you use doesn’t matter. Here’s the basic idea:

Step 1: Set Up Empties to Track Bone Movement

  • Place an empty at the location of each animated bone.
  • Parent each empty to its corresponding bone. This way, it mimics the bone’s motion.
  • For each bone, add a Copy Rotation constraint that follows the empty.

Step 2: Add Control Empties

  • For major joints (e.g., shoulders, knees), create visible empties like cubes or arrows for animation controls.
  • Add Copy Location, Copy Rotation, or IK constraints to the bones, referencing these control empties.

This creates a separation between the original animation data (now on the empties) and the character rig, so you can freely swap or edit the mesh without losing motion fidelity.

Automating the Process

Doing this manually for every bone across multiple rigs is still time-consuming. Here’s how to streamline it:

1. Record Actions with the Info Panel

In Blender, open the Info panel to view Python commands for every action you perform. Use this to capture the steps needed to:

  • Add empties at bone positions
  • Parent them to bones
  • Apply constraints

This gives you a template for your automation script.

2. Choose Your Scripting Strategy

Option A: Blender Add-on (for GUI integration)

  • Ideal for small-scale use inside Blender.
  • Cleaner user interface, but limited to one .blend file at a time.

Option B: External Python Script using bpy

  • Best for batch processing characters in multiple .blend files.
  • Can use os or tkinter to navigate folders and process assets in bulk.

⚠️ Reminder: bpy can only access one .blend file at a time. Use this approach to load data:

with bpy.data.libraries.load('darts.blend') as (data_from, data_to):
    data_to.objects = data_from.objects

Avoid trying to open multiple .blend files simultaneously in the same script—Blender doesn’t support that.

3. Automate Naming and Selection

Hardcoding names of bones and objects is fragile. Instead:

  • Use loops to iterate through selected bones or objects.
  • Use naming patterns or Blender’s data hierarchy to locate targets dynamically.

Wrap-Up

This workflow lets you keep your animation data intact, even after modifying the mesh or retargeting the character. Once you have a working automation script, you can scale it up across an entire library of assets.

A sample result is shown in the attached video.

“I could do it by hand but it would take me all year. I can’t describe how incredible your work and help has been but I think it would be cool, down the road, to make you a gift model of some sort.”
Roghroo, 1/25/24