As you guys can see, the guys at Epic have taken a bunch of pieces of the Anim Instance class and wrapped them in a helper method.
So what is this method doing ?
Well it brings in the AnimInstance from our Mesh object by calling GetAnimInstance().
Then it validates that the montage we want to interact with is available and the Anim Instance is not null.
If that passes it then kicks off the Montage_Play method right on the Anim Instance by passing in the montage and the Play Rate.
So far so good.
We then look at a few more conditionals that just ensure the data that is required is available to us.
And then lastly it calls Montage_JumpToSection as the overall method takes in a StartSectionName value that determines the playback position.
Even Epic likes Anim Instances ? How do I subscribe to their newsletter ?
Well you can do that through their web site or simply by getting a reference to your local neighborhood Anim Instance and start performing some of these operations.
What are these common operations ?
There are a bunch of them but let’s go over the immediately meaningful ones.
Montage_Stop– stops the montage and blends in the next animation using the blend speed parameter. Good for killing montages mid playback.
// takes in a blend speed ( 1.0f ) as well as the montage
Montage_Pause– pauses the current animation and freezes parts of the object tied to those animations. In our case we are able to pause a punch mid stream. Great for effects where you need to halt an animation, do some other activities and then resume.
// takes in the montage you want to pause
Montage_Resume– called after you call Montage_Pause as it will resume the playback of the animation from that point in time.
// takes in the montage you want to resume playback for
Montage_Play – triggers the playback of an animation based on various criteria like montage, speed, return type, playback start position and a control variable to stop other montages if they are currently executing.
// kicks off the playback at a steady rate of 1 and starts playback at 0 frames
AnimInstance->Montage_Play(AttackMontage->Montage, 1.0f, EMontagePlayReturnType::Duration, 0.0f, true);
Montage_GetPosition– returns the current position of the playback frames as they are contained within the duration of the animation.
// returns current playback position
float CurrentPosition = AnimInstance->Montage_GetPosition(AttackMontage->Montage)
Montage_IsPlaying– returns a boolean to let the caller know if we have an active animation.
// checks to see if any animations in a montage are active
Montage_JumpToSectionUAnimInstance– moves the animation starting point to the location of the section as it’s setup in the Animation Montage.
// starts the animation at a specific section
Pretty neat eh !
As you can see, we get a lot freedom with access to anim instances as well as the ability to control our animations easily.
Not a huge collection of additional resources but here is the doc to the UAnimInstanceclass: