I’ve an AI that is using montage with separate Sections that play different attack animations. I would like to know how much time each sections take so I can trigger another attack after first one ended animation. I’m using behavior tree and task to pick sections, and I need a delay (time of the montage section) to end the task.
Anyone know how to do that?
Try putting a function like this in your class extending AnimInstance, and pass in the montage you want the total time of.
float UYourAnimInstance::MontageGetAllSequenceTimes(UAnimMontage* montage)
{
float time = 0.0;
TArray<UAnimSequence*> AnimationSequences;
montage->GetAllAnimationSequencesReferred(AnimationSequences);
for (int32 i = 0; i < AnimationSequences.Num(); i++)
{
UAnimSequence* seq = Cast<UAnimSequence>(AnimationSequences[i]);
time += seq->SequenceLength;
}
return time;
}