How can I assign variables of animation blueprints in runtime?

Hello, I’m trying to spawn one of random Metahuman classes on the runtime, and trying to retarget existing mesh’s animation onto the Metahuman. I’m trying to do this by refering to Retargeting Animations to a MetaHuman at Runtime | MetaHuman Creator Documentation, but it didn’t work out well. I didn’t exactly follow the manual, because I want to use a lot different kind of Metahuman and cannot manually set up things for each Metahuman class.


This is the animation blueprint (BP_RetargetToMetaHuman) I’m using, and I’m trying to assign a mesh in a character blueprint to “Source Mesh Component”


For full context, in character’s blueprint a random MetaHuman is spawned, and the MetaHuman as an actor is passed to the “SetRetargetAnim” function I’m struggling with.


This is the part of “SetRetargetAnim” function, where I tried to set anim intance class to “BP_RetargetToMetaHuman” and attempted to set “Source Mesh Component” of it. I added stop animation node to see if cast fails, and it looks like it fails

This is “Get Body Mesh” macro used in the function above, which gets “Body” skeletal mesh from MetaHuman actor, to make it clear.

So I want to know how to correctly set “Source Mesh Component” variable at the runtime to retarget animation from source mesh to the Metahuman. Or alternatively is there a way to assign the variable when I set anim instance class for the mesh?

Does your animation blueprint “BP_RetargetToMetaHuman” use the same skeleton as the skeletal mesh you’re trying to assign it to?

If it’s not then I think the “Set Anim Instance Class” node will not do anything, and your cast afterwards will fail.

I was using template animation blueprint, so it doesn’t have target meshed specified

Is there a way to instantiate it in the blueprint for the target skeleton mesh and set anim instance class to that?