I have code that jumps to a specific section in a montage, plays it, and gets the length of the section as such:
mesh->GetAnimInstance()->Montage_JumpToSection(sectionName, montage);
mesh->GetAnimInstance()->Montage_Play(montage);
float animLength = montage->GetSectionLength(sectionIndex);
The problem is finding out sectionIndex
. I have checked for a while but there doesn’t seem to be any function to get it, or at least a function to get the length by name instead of index. How can I get the index of 1) the current playing section, and/or 2) a specific section by name?
Dartanlla
(Dartanlla)
December 26, 2016, 4:55pm
2
From the source code on GitHub:
int32 UAnimMontage::GetSectionIndex(FName InSectionName) const
Will get you a SectionIndex from a SectionName
so change your code to:
mesh->GetAnimInstance()->Montage_JumpToSection(sectionName, montage);
mesh->GetAnimInstance()->Montage_Play(montage);
int32 sectionIndex = montage->GetSectionIndex(sectionName);
float animLength = montage->GetSectionLength(sectionIndex);
or something like that and you should be all set.
Had no idea it was seriously that easy as nothing showed up in intellisense…should’ve properly checked the docs, thanks!