RealDocs

UAnimInstance::GetRootMotionMontageInstance

function Engine Since 4.0
#include "Animation/AnimInstance.h"
Access: public Specifiers: ENGINE_API

Description

Returns a pointer to the currently active montage instance that is providing root motion, or nullptr if no montage is currently driving root motion. Use this to inspect or manipulate the root-motion-contributing montage directly.

Caveats & Gotchas

  • The returned pointer is only valid for the current frame. Montage instances can be recycled or destroyed between ticks, so do not cache this pointer across frames.
  • When multiple montages are playing simultaneously in different slots, only one can be the root motion source. This function returns whichever montage the system has designated as the current root motion provider, which is the highest-priority active montage with root motion enabled.

Signature

ENGINE_API FAnimMontageInstance* GetRootMotionMontageInstance() const;

Return Type

FAnimMontageInstance*

Example

Query the current root motion montage C++
void UMyAnimInstance::LogRootMotionMontage()
{
	if (FAnimMontageInstance* RMInstance = GetRootMotionMontageInstance())
	{
		UE_LOG(LogAnimation, Log, TEXT("Root motion from: %s at position %.2f"),
			*RMInstance->Montage->GetName(), RMInstance->GetPosition());
	}
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.