x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to resume animation montage after pause

Hi. I have a question about how to resume animation montage after pause. For example:

 /** Pauses the animation montage. If reference is NULL, it will stop ALL active montages. */
     UFUNCTION(BlueprintCallable, Category = "Animation")
     void Montage_Pause(UAnimMontage * Montage = NULL);

How to correctly resume to play state? I am tying to use Montage_Play and have unexpected results.

Product Version: UE 4.11
Tags:
more ▼

asked Apr 22 '16 at 10:05 AM in C++ Programming

avatar image

v.s.
347 9 12 26

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I don't see one, but if you want to add it to your codebase I image this would work:

AnimMontage.h:

 void Resume() { bPlaying = true; }

AnimInstance.h:

 UFUNCTION(BlueprintCallable, Category = "Animation")
 void Montage_Resume(UAnimMontage * Montage = NULL);

AnimInstance.cpp:

 void UAnimInstance::Montage_Resume(UAnimMontage* Montage)
 {
     if (Montage)
     {
         FAnimMontageInstance* MontageInstance = GetActiveInstanceForMontage(*Montage);
         if (MontageInstance)
         {
             MontageInstance->Resume();
         }
     }
 }
more ▼

answered Apr 23 '16 at 05:18 AM

avatar image

rantrod
1.5k 48 47 216

avatar image v.s. Apr 23 '16 at 08:46 AM

Thanks for your answer. But it is not a solution. I am trying to do bPlaying = true but this is not enough. I am doing a next sequence of actions:

My character is falling (dead). Before this:

 if (AnimInstance->Montage_IsPlaying(Montage))
     AnimInstance->Montage_JumpToSection(Montage->GetSectionName(SectionID), Montage);
 else
     Character->PlayAnimMontage(Montage, 1.f, Montage->GetSectionName(SectionID));
 Memory->Interval = Montage->GetSectionLength(SectionID);

Next I am waiting for Memory->Interval. After it was expired I am freezing the pose of the character:

 auto MeshComponent = GetMesh();
 MeshComponent->GlobalAnimRateScale = 0.f;
 GetAnimInstance()->Montage_Pause();

Then my character has begun to recovery.

 // Unfreeze
 auto MeshComponent = GetMesh();
 MeshComponent->GlobalAnimRateScale = 1.f;

 if (AnimInstance->Montage_IsPlaying(Montage))
     AnimInstance->Montage_JumpToSection(Montage->GetSectionName(SectionID), Montage);
 else
     Character->PlayAnimMontage(Montage, 1.f, Montage->GetSectionName(SectionID));    
 Memory->RecoveryInterval = Montage->GetSectionLength(SectionID);

I am waiting for recovery. And character was killed during recovery. And we are following to paragraph 1. At this point I am waiting for section playing. But at the end of playing montage was interrupted (blendout = 0). All sections was looped and I can not understand the reason for an interrupt.

avatar image rantrod Apr 26 '16 at 02:46 AM

Sorry, but I don't see a way around that problem. There's code in the animation system that automatically kills the animation if it's paused (i.e. the weight is zero). It would be a rats nest to try to fix that.

My only other suggestion is to slow it down a lot, then restore it. Pause by calling SetPlayRate(0.001f), then restore by calling SetPlayRate(1.0f).

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question