Animation Montage Loop

I am having a problem. I created a animation montage with a beginning segment, a middle segment that loops and an end segment (It’s an aiming animation for when you are in cover). I want the middle segment to loop while “right click” is held down. When release “right click” I want to play the end segment of the animation montage. Currently the beginning segment plays great, the middle segment loops correctly but when I release “right click” it doesn’t play the end segment of the animation montage

Here is the code:

void AArenaCharacter::OnStartTargeting()
{
	AArenaPlayerController* MyPC = Cast<AArenaPlayerController>(Controller);
	if (MyPC && MyPC->IsGameInputAllowed() && bInCombat == true)
	{
		IdleTime = 0.0f;
		if (IsRunning())
		{
			SetRunning(false, false);
		}
		GetCharacterMovement()->MaxWalkSpeed = TargetingMovementSpeed;
		SetTargeting(true);
		PlayAnimMontage(AimHiLeftAnimation);
	}
}

void AArenaCharacter::OnStopTargeting()
{
	if (bInCombat == true)
	{
		GetCharacterMovement()->MaxWalkSpeed = BaseMovementSpeed;
		SetTargeting(false);
		StopAnimMontage(AimHiLeftAnimation);
	}
}

Hi, you should use

AimHiLeftAnimation->SetNextSectionName(FName(“AimingL”), FName(“StopAimingL”));

instead of

StopAnimMontage(AimHiLeftAnimation);

Thanks for the reply. I am trying it our but AnimationMontage doesn’t appear to have a method called “SetNextSectionName()” do you know if they changed the name perhaps?

I’m sorry i was looking at the AnimMontageInstance class… I was confused by the methods exposed to Blueprint by AnimInstance

It appears “GetActiveInstanceForMontage” no longer works. Maybe they changed the way they do it but the documentation doesn’t mention on changes

 FAnimMontageInstance * MontageInstance = GetActiveInstanceForMontage(*Montage);
            if (MontageInstance)
            {
                MontageInstance->SetNextSectionName(SectionNameToChange, NextSection);
            }

Wondering if you have figured it out?

Thanks

I’m sorry, i only tried AnimMontages with Blueprint i tried to adapt what i did in BP to help you with your C++ version