Figured it out in C++. I had to add the dynamic changing code in the Character class itself.
template <typename ObjClass>
static FORCEINLINE ObjClass* LoadObjFromPathPTR(const FName& Path)
{
if (Path == NAME_None) return NULL;
return Cast<ObjClass>(StaticLoadObject(ObjClass::StaticClass(), NULL, *Path.ToString()));
}
// Load Static Mesh From Path
static FORCEINLINE USkeletalMesh* LoadSkelMeshFromPath(const FName& Path)
{
if (Path == NAME_None) return NULL;
return LoadObjFromPathPTR<USkeletalMesh>(Path);
}
// Load Static Mesh From Path
static FORCEINLINE UAnimBlueprint* LoadAnimBPFromPath(const FName& Path)
{
if (Path == NAME_None) return NULL;
return LoadObjFromPathPTR<UAnimBlueprint>(Path);
}
void AAI_PartyMemeber::SetupDynamicSkelAndAnima(FString Skel,FString Anim)
{
USkeletalMesh* skelObject = LoadSkelMeshFromPath(*Skel);//load the object as per tutorial below or use static load object directly, or use ObjectFinder.
if (skelObject && Mesh)
{
Mesh->SetSkeletalMesh(skelObject);
}
UAnimBlueprint* AnimObject = LoadAnimBPFromPath(*Anim);//load the object as per tutorial below or use static load object directly, or use ObjectFinder.
if (AnimObject && Mesh)
{
Mesh->SetAnimClass(AnimObject->GetAnimBlueprintGeneratedClass());
}
}