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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

AnimMontage for melee combo.

I have many animations of melee attacks. I have all of them in one AnimMontage. I would like to play the first animation, then if the player presses again the attack button playing the next one and so on, otherwise stop the AnimMontage from playing.

If I play an anim montage this way:

 return GetPawnMesh()->AnimScriptInstance->Montage_Play(AnimMontage, InPlayRate);

How can I set what section to play each time on that AnimMontage and what can I set to stop it? I have created a TestAnimMontage similar to the one I can see here:https://rocket.unrealengine.com/docs/ue4/INT/Engine/Subsystems/Animation/AnimMontage/index.html. But I need to handle everything from code (if it is possible).

Product Version: Not Selected
more ▼

asked Mar 11 '14 at 02:40 AM in C++ Programming

avatar image

ue4-archive ♦♦ STAFF
49.9k 3665 1991 9119

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

1 answer: sort voted first


To do really fancy stuff and make your own modified anim montage playing code,

You should

  • extend your own anim instance from UAnimInstance

  • reparent your animation blueprint to use your anim instance

  • check out these awesome functions!

    Functions of Great Pertinence


 /** Makes a montage jump to a named section. */
     UFUNCTION(BlueprintCallable, Category="Animation")
     void Montage_JumpToSection(FName SectionName);
     /** Makes a montage jump to the end of a named section. */
     UFUNCTION(BlueprintCallable, Category="Animation")
     void Montage_JumpToSectionsEnd(FName SectionName);
     /** Changes the next section in the montage to a different one. */
     UFUNCTION(BlueprintCallable, Category="Animation")
     void Montage_SetNextSection(FName SectionNameToChange, FName NextSection);

 /** Returns the name of the current animation montage section. */
     UFUNCTION(BlueprintCallable, Category="Animation")
     FName Montage_GetCurrentSection();


Also, you can get and set exact positions as well!

 /** Get Current Montage Position */
     float Montage_GetPosition(UAnimMontage* Montage);
     /** Has Montage been stopped? */
     bool Montage_GetIsStopped(UAnimMontage* Montage);
     /** Set position. */
     void Montage_SetPosition(UAnimMontage* Montage, float NewPosition);
     /** Get PlayRate */
     float Montage_GetPlayRate(UAnimMontage* Montage);
     /** Set PlayRate */
     void Montage_SetPlayRate(UAnimMontage* Montage, float NewPlayRate);
     /** Get next sectionID for given section ID */
     int32 Montage_GetNextSectionID(UAnimMontage* Montage, int32 CurrentSectionID);

more ▼

answered Mar 11 '14 at 02:40 AM

avatar image

ue4-archive ♦♦ STAFF
49.9k 3665 1991 9119

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:40 AM

Thanks, I'll start playing with them.

After having done all those steps can the general idea be:

  1. The input makes the AnimMontage to start playing

  2. The next input of the player calls JumpToSection to play the next attack animation inside the AnimMontage

  3. In case I have to stop the combo I use JumpToSectionsEnd.

As Montage_JumpToSection doesn't take a AnimMontage as a parameter I suppose it is performed on the currently active AnimMontage. Isn't it?

I am trying in this way just to run a test before start implementing my own code but I can't switch section. Is my idea of playing the montage and then changine section wrong?

 UseMesh->AnimScriptInstance->Montage_Play(AnimMontage, InPlayRate);
         FName name("Swing1");

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:40 AM

you are going to have to experiment and find out for yourself, I've not used these functions in depth yet.

If you encounter a specific issue that seems like a bug let us know!


avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:40 AM

well im not sure if it is a typo in your copy pasting

but this

 FName name("Swing1");

should definitely be this!

 FName name("Swing1");

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:40 AM

No, it was actually an error!!! I was passing another variable to it. Currently I am using it and it seems to work well. I'll experiment a little with all the other functions.


(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