UAnimInstance::Montage_Play
#include "Animation/AnimInstance.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallable
Description
Plays an animation montage on this anim instance. Returns the montage length in seconds (or duration at play rate), or 0.0 if it failed to play.
Caveats & Gotchas
- • Returns 0.0 on failure — always check the return value if you need to chain logic after playback.
- • By default bStopAllMontages=true, which interrupts any currently playing montage. Pass false to layer montages in separate slots.
- • Must be called on the anim instance, not the mesh component directly. Get it via USkeletalMeshComponent::GetAnimInstance().
- • The montage slot in the anim graph must be active and weighted for the montage to visually play.
Signature
float Montage_Play(UAnimMontage* MontageToPlay, float InPlayRate = 1.f, EMontagePlayReturnType ReturnValueType = EMontagePlayReturnType::MontageLength, float InTimeToStartMontageAt = 0.f, bool bStopAllMontages = true) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| MontageToPlay | UAnimMontage* | The montage asset to play. | — |
| InPlayRate | float | Playback speed multiplier. 1.0 is normal speed. | 1.f |
| ReturnValueType | EMontagePlayReturnType | Whether to return the montage length or the duration at the given play rate. | EMontagePlayReturnType::MontageLength |
| InTimeToStartMontageAt | float | Position in seconds to start playback from. | 0.f |
| bStopAllMontages | bool | If true, stops all other active montages before playing. | true |
Return Type
float Example
Play a montage and get its length C++
if (UAnimInstance* AnimInst = GetMesh()->GetAnimInstance())
{
float Duration = AnimInst->Montage_Play(AttackMontage, 1.f);
if (Duration > 0.f)
{
// Montage started successfully
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?