UAnimInstance::PlaySlotAnimationAsDynamicMontage
#include "Animation/AnimInstance.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallable
Description
Creates a transient UAnimMontage wrapping the given asset and plays it through the named slot node. Use this to play one-off sequences without authoring a montage asset.
Caveats & Gotchas
- • Only one asset can play per SlotGroup at a time — calling this again on the same slot interrupts the current animation immediately with a new blend-in.
- • The returned UAnimMontage is dynamically created and destroyed when playback ends; caching the pointer beyond that frame is unsafe unless you hold a strong reference.
- • If the slot node name does not exist in the anim graph the call silently fails and returns nullptr.
Signature
ENGINE_API UAnimMontage* PlaySlotAnimationAsDynamicMontage(UAnimSequenceBase* Asset, FName SlotNodeName, float BlendInTime = 0.25f, float BlendOutTime = 0.25f, float InPlayRate = 1.f, int32 LoopCount = 1, float BlendOutTriggerTime = -1.f, float InTimeToStartMontageAt = 0.f); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Asset | UAnimSequenceBase* | The animation sequence or blend space to play. | — |
| SlotNodeName | FName | Name of the slot node in the anim graph where the montage will be inserted. | — |
| BlendInTime | float | Seconds to blend in from the underlying pose. | 0.25f |
| BlendOutTime | float | Seconds to blend back to the underlying pose after the animation ends. | 0.25f |
| InPlayRate | float | Playback speed multiplier; 1.0 is normal speed. | 1.f |
| LoopCount | int32 | Number of times to loop; 1 plays once. | 1 |
| BlendOutTriggerTime | float | Time before the end of the montage at which blending out begins. -1 uses the montage's default. | -1.f |
| InTimeToStartMontageAt | float | Position in the asset (in seconds) at which playback starts. | 0.f |
Return Type
UAnimMontage* Example
Play a reload animation on a weapon slot C++
if (UAnimInstance* AnimInst = GetMesh()->GetAnimInstance())
{
AnimInst->PlaySlotAnimationAsDynamicMontage(
ReloadAnim,
FName("WeaponSlot"),
0.1f, // blend in
0.2f, // blend out
1.0f, // play rate
1 // play once
);
} See Also
Tags
Version History
Introduced in: 4.8
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?