C++ Flipbook complete animation when pressing a key

Hello everyone!
I recently started a c++ project and right now I’m dealing with flipbook animations. I doing a top-down 2d Hack n’ Slash and I want my character to do a complete animation (all frames of the flipbook) when I press Z. I can only do this if I keep pressing the Z key as I can’t find any other way. So right now, when I press Z and realese it imediatly, it only renders the first frama of the animation. I want to press Z and realease and render the all animation.

void AHunter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
	InputComponent->BindAction("Sword_Attack", IE_Pressed, this, &AHunter::BeginSwordAttack);
	InputComponent->BindAction("Sword_Attack", IE_Released, this, &AHunter::StopSwordAttack);

...

}

void AHunter::UpdateAnimation()
{
	const FVector PlayerVelocity = GetVelocity();
	bool PlayerOrientation = true;
	UPaperFlipbook* DesiredAnimation = IdleDownAnimation;

...

	// Are we attacking?
	if (bAttacking) {
		DesiredAnimation = AttackDownAnimation;
	}

	//Update sprite
	if (GetSprite()->GetFlipbook() != DesiredAnimation)
	{
		GetSprite()->SetFlipbook(DesiredAnimation);
	}

	
}

void AHunter::BeginSwordAttack() {
	bAttacking = true;
}

void AHunter::StopSwordAttack() {
	bAttacking = false;
}

This is what I have right now.

Thank you :slight_smile: