Hello, I’ve been able to get Curves and Notify’s from animations just fine, but I’m having a hard time getting or setting animation variables so the animations will actually play.
Here is how I got the curves and notifys:
void AUnit::BeginPlay(){
Super::BeginPlay();
Animation = Mesh->GetAnimInstance();
}
void AUnit::Tick(float DeltaTime){
Super::Tick(DeltaTime);
//Get Animation Curve
float val = Animation->GetCurveValue(FName("Curve"));
//Get Animation Notifies
TArray<const struct FAnimNotifyEvent*> AnimNotifies = Animation->AnimNotifies;
for (int i = 0; i < AnimNotifies.Num(); i++){
AnimNotifies[i]->NotifyName.ToString();
}
//Get/Set Animation Variables.. These are fake,
//but I'm looking for something like this:
Animation->SetBool("inAir", true);
Animation->GetFloat("speed");
}
Now I can’t seem to figure out how to access the variables through the AnimInstance.
Any help would be greatly appreciated!
Thanks!
Bonus: If you know how to directly play/crossfade an animation through code that would be great too!
Edit:
I ended up using that method. The code on that page has some errors as it’s a few years old and it’s missing some steps, but in the end it works. If you want to post that as an answer, I’d be glad to mark it as the correct asnwer.