Change Skeleton Hierarchy

I have decided to change the Hierarchy of my main skeleton, that is associated with lots of Skeleton meshes.
I do understand the concept that “the bone hierarchy from one Skeletal Mesh to another cannot be violated.”

My question is what should I do to maintain my Skeletal meshes and all the Skeleton animations, having Skeleton hierarchy change?

I simply need to change the parenting top down.

1 Like

Is there any way to reimport skeleton or something? I really have a lot of animation for retargeting otherwise :frowning:

I know it is an old question, but I am facing the same issue now.
What I found might be useful for others, I have tested two approaches:

  1. Export the skeletal mesh → edit it externally (I have used blender) → reimport it back. This approach works fine, but I have some problems with import/export parameters, so I lose some information.
  2. Use the Skeletal Editor official plugin (Skeletal Editor Usage Guide | Tutorial). This works fine, except for the fact that it is still under-development, so it makes the Engine crash sometimes. In my case, it was not effective (but it might be possible that it was up to me).

So if anyone has any suggestion or hint on how to solve this issue, please continue this discussion, thank you.

I manage to fix my problem with the Skeletal Editor plugin.
I have used the python scripting, because I think it is more stable than the interface.

This is the first code I have used to edit the skeletal structure.
(replace with the path of your skeletal mesh, be aware that the /Game/ folder is by default the content folder).

import unreal

asset_editor = unreal.EditorAssetLibrary()
file_path = '/Game/<insertThePathToYourSkeletalMesh>'

# get the skeletal mesh
skel_mesh = asset_editor.load_asset(file_path)

# load the skeleton modifier
skeleton_modifier = unreal.SkeletonModifier()

# set the skeletal mesh to modify
skeleton_modifier.set_skeletal_mesh(skel_mesh)

# Reparent bones using their name
skeleton_modifier.parent_bone("bone_a", "bone_c")
skeleton_modifier.parent_bone("bone_d", "bone_e")

# Commit the changes
skeleton_modifier.commit_skeleton_to_skeletal_mesh()

This worked fine to modify both the skeleton and the skeletal mesh automatically, but it makes the Engine crash as soon as I try to use the skeletal mesh, for example to define the IK rig.

I noticed that the problem was related to the normalization of the rotations in the Skeleton, so I just add a simple check for rotation normalization.

all_bone_names = skeleton_modifier.get_all_bone_names()

for bone_name in all_bone_names:
    bone_transform = skeleton_modifier.get_bone_transform(bone_name)
    bone_quat = bone_transform.get_editor_property("rotation")
    if( not bone_quat.is_normalized()):
        normalized_quat = bone_quat.normalized()
        bone_transform.set_editor_property("rotation",normalized_quat)
        applyToAllChildern = False
        skeleton_modifier.set_bone_transform(bone_name, bone_transform, applyToChildern)

Hope this will be helpful to others

1 Like