In this lesson, you will learn how to manipulate the PlayRate of an Animation Montage in real-time to reflect a character's changing physical state during combat.
Why Change Playback Rates?
Standard animations are authored at a fixed speed, but gameplay often requires fluidity. Imagine a character getting exhausted: their sword swing should start fast but progressively slow down as stamina depletes. By adjusting the PlayRate dynamically, you can simulate fatigue, power-ups, or status effects like "slow" or "haste" without needing to create unique animation assets for every scenario.
The Mechanics of PlayRate
When you trigger an animation via Play Montage At Location or Play Anim Montage, the PlayRate parameter defaults to 1.0. Setting this to 2.0 doubles the speed, while 0.5 cuts it in half.
To adjust this dynamically during a montage, you use the Play Montage node to store the MontageInstance reference. You can then use the Set Play Rate function provided by the AnimInstance to modify the speed of a specific, currently playing montage.
// Example: Setting the Play Rate of a running montage
// Assuming 'AnimInstance' is cached and 'TargetRate' is your calculated float
if (UAnimInstance* AnimInstance = GetMesh()->GetAnimInstance())
{
AnimInstance->Montage_SetPlayRate(MyMontageReference, TargetRate);
}
Practical Application: The Exhaustion System
A common way to implement this is to link the PlayRate variable to a "Stamina" or "Strength" value in your character’s Tick or a status effect event. If your stamina is at 100%, keep the rate at 1.0. As stamina drops toward 0%, use a Map Range Clamped node to interpolate the PlayRate from 1.0 down to 0.5.
Because this happens on the active MontageInstance, the transition is seamless—the animation doesn't restart; it simply speeds up or slows down based on your logic. This keeps your combat feeling responsive to the player’s current status while utilizing the same high-quality animation assets.
Key Takeaway: Use Montage_SetPlayRate to adjust the speed of an active animation on the fly, allowing you to procedurally reflect character status without needing custom assets for every speed variation.