How to set the Bone Map from GDScript?

Godot Version

Godot v4.3.rc3.mono - Linux Mint 22 (Wilma) - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4060 Ti (nvidia; 535.183.01) - AMD Ryzen 7 5700X 8-Core Processor (16 Threads)

Question

How do I set the Bone Map from a bone_map.tres via GDScript?

I want to do the equivilent of setting the retargetting of the bone map by loading the bone_map.tres file in the Advanced Import pane.

I have been all over the docs and just can’t find the answer.

1 Like

I would add a Question to this, if anyone find the anser is there any possibility to set the BoneMap via : EditorScenePostImport ? (the Import Script)
and in the same vibe how can we create Preset for imports ?

So I guess I never came back to this.

So the short answer is “you can’t”, both to my question and to @g-raffiti 's question as well. I spoke to Lyuma about it and he is working on improving the API. I was hoping to see that in 4.4, but he didn’t get it in on time. Maybe 4.5 will see the API enhancement.

The reason it won’t work in post import is the bones need to be assigned pre-import, so it know how to assign the rigging to the bones not-post import. The bone assignments need to be there already when importing the assets using the post import script, if you do it after, the asset rig isn’t mapped to the bones.

As I mentioned, it is being worked on, but I do not have a timeline and I don’t want to make promises on someone’s elses behalf. You can read about it in this issue if you wish and also learn some partial workarounds that “sorta” get you there, but won’t let you fully automate importation of more than one animation library at a time.