I have a Paper2D Character class in a fighting game. For now, it has 3 animation flipbooks: IdleAnimation, RunningAnimation, and AttackAnimation. I have a function, Attack(), that is supposed to set the current flipbook to the AttackAnimation, and play the whole AttackAnimation flipbook once. Earlier, I tried this, which compiled before (for some reason, now it doesn’t) but does not play the animation:
void Fighter::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent){
/* default sidescroller character jumping/moving*/
PlayerInputComponent->BindAction("Attack", IE_Pressed, this, &Fighter::Attack);
/* default sidescroller character button press/release */
}
void Fighter::Attack() {
FTimerHandle delay;
GetSprite()->SetFlipbook(AttackAnimation);
float i = GetSprite()->GetFlipbookLength();
GetWorldTimerManager().SetTimer(delay, &Fighter::OnAttackTimer, 1.0f, true, i);
}
void Fighter::OnAttackTimer() {
GetSprite()->SetFlipbook(AttackAnimation);
}
I have the character correctly possessed by a PlayerController, and the input key for attacking is defined, so I’m at a loss as to why the animation doesn’t play.