You can stick that piece of code pretty much anywhere and expose it to blueprints:
in the .h file (in a ‘public’ section) of the class you want to put this in:
UFUNCTION(BlueprintCallable, Category = "AnimData")
FTransform GetBoneTransformAtTime(UAnimSequence* MyAnimSequence, float AnimTime, int BoneIdx, bool bUseRawDataOnly);
in your .cpp file:
FTransform YourClass::GetBoneTransformAtTime(UAnimSequence* MyAnimSequence, float AnimTime, int BoneIdx, bool bUseRawDataOnly)
{
const TArray<FTrackToSkeletonMap> & TrackToSkeletonMap = bUseRawDataOnly ? MyAnimSequence->TrackToSkeletonMapTable : MyAnimSequence->CompressedTrackToSkeletonMapTable;
if ((TrackToSkeletonMap.Num() > 0) && (TrackToSkeletonMap[0].BoneTreeIndex == 0))
{
return MyAnimSequence->GetBoneTransform(BoneTransform, BoneIdx, AnimTime, bUseRawDataOnly);
}
return FTransform::Identity;
}
You can put it in an actor class, but you’d want to keep it generic so if your project has a ‘GameplayStatics’, it’s better there (you can create your own deriving from the Engine’s version).