Animation : Find time of global min/max position of a given bone

Hey,

given a bone and an animation I’d like to get the time when that bone is at it’s highest/ lowest position. ( and then create notifys at those times )

I’ve searched through UAnimSequence and its parents. My idea would be to use

UAnimSequence::ExtractBoneTransform(
    const struct FRawAnimSequenceTrack & InRawAnimationTrack,
    FTransform & OutAtom,
    float Time)

and interate through the length of the animation to get an array of transforms over the whole animation. But I doubt this will be enough to find the max/min position since the bone is affected by its parents in the hierarchy. So even if I found a min/max position this would be a local min/max and not a global one, right ?

Does anyone know an easier way to do this?

I solved it with the following code, please correct me if something is wrong

int GetFrameOfLowestPosition(UAnimSequence * anim, FName BoneName)
{
	FName ParentBone;
	FTransform Pose;
	FTransform ParentPose;
	TArray<FTransform> Transforms;
	const int32  NumFrames = anim->GetNumberOfFrames();

	for (int i = 0; i < NumFrames; ++i) {
		ParentBone =  PlayerMesh->GetParentBone(BoneName);
		UAnimationBlueprintLibrary::GetBonePoseForFrame(anim, BoneName, i, false, Pose);

		while (ParentBone != "None") {
			UAnimationBlueprintLibrary::GetBonePoseForFrame(anim, ParentBone, i, false, ParentPose);
			Pose = Pose * ParentPose;
			ParentBone = PlayerMesh->GetParentBone(ParentBone);
		}

		Transforms.Add(Pose);
	}

	float Minimum = MAX_flt;
	int key = 0;

	for (int j = 0; j < Transforms.Num(); ++j) {
		if (Transforms[j].GetLocation().Z <= Minimum) {
			Minimum = Transforms[j].GetLocation().Z;
			key = j;
		}
	}

	return key;
}