I have this code to query UAnimMontage data, GetSectionLength and GetSectionMetaData), in my AnimInstance.
This code worked for the time being.
But I’m new to C++, so I’m not sure whether this code is correct or having something wrong.
I’d like you to see this code, and if there are something wrong, please point out problem.
UMyAnimInstance.h
#pragma once
#include "Animation/AnimInstance.h"
#include "MyAnimInstance.generated.h"
/**
*
*/
UCLASS()
class AITEST411_API UMyAnimInstance : public UAnimInstance
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "MyFunction")
float GetCurrentSectionLength(UAnimMontage * Montage, FName SectionName);
UFUNCTION(BlueprintCallable, Category = "MyFunction")
TArray< class UAnimMetaData * > GetCurrentMetaData(UAnimMontage * Montage, FName PlayingSection);
};
UMyAnimInstance.cpp
#include "AItest411.h"
#include "MyAnimInstance.h"
float UMyAnimInstance::GetCurrentSectionLength(UAnimMontage * Montage, FName SectionName)
{
int32 SectionIndex = Montage->GetSectionIndex(SectionName);
return Montage->GetSectionLength(SectionIndex);
}
TArray< class UAnimMetaData * > UMyAnimInstance::GetCurrentMetaData(UAnimMontage * Montage, FName PlyaingSection)
{
FName SectionName = PlyaingSection;
return Montage->GetSectionMetaData(SectionName);
}
Sorry for my poor English, and strange Question.
And I’ve also posted this question Japanese Section , QuestionPost, because of there is few C++ user.
Again, I’m sorry for multi-post, but if answerd in Japanese Section, I’ll report here!