AnimBlueprint Montage Get current time

I want to be able to translate the character an amount each update while a montage with root motion is playing, to basically tweak it to a variable end location.

On the AnimBlueprint:
How do I get the total time/length of a montage?
How do I get the current time in the montage?

bump, I still haven’t solved this, I put the task that needed it aside for a while. Does anyone know how to get the time remaining on a Montage that is playing?

#Anim Instance

Everything you need is in the Anim Instance class!

You need to create a custom anim instance class for your project.

Then reparent your animation blueprint to use this custom anim instance class as its base class (File->ReParent)

Then checkout AnimInstance.h!

All the functions you want are there, including what the currently playing montage is, so you can then access any info you want about it!

You retrieve your custom anim instance at runtime from your character like this:

//inside Character class

if(!Mesh) return;
//~~~~~~~~~~~~~~~
 

UYourAnimInstance * Animation = 
  Cast<UYourAnimInstance>( Mesh->GetAnimInstance() );

if(!Animation) return;

//Now you can do stuff with your custom vars or functions in your anim instance class!

Animation->Celebrate(); //custom function in your anim instance C++ class

**My Anim Instance Tutorials**

Two relevant tutorials of mine here, with **C++ Code class structure and pics!**

https://wiki.unrealengine.com/Animation_Blueprint,_Set_Custom_Variables_Via_C%2B%2B

https://wiki.unrealengine.com/Animation_Blueprint,_Implement_Custom_C%2B%2B_Logic_Via_Tick_Updates

Anim Instance Functions relevant to your question

public:
	/** Get Current Montage Position */
	float Montage_GetPosition(UAnimMontage* Montage);
	/** Has Montage been stopped? */
	bool Montage_GetIsStopped(UAnimMontage* Montage);

	/** Set position. */
	void Montage_SetPosition(UAnimMontage* Montage, float NewPosition);

	/** Get PlayRate */
	float Montage_GetPlayRate(UAnimMontage* Montage);

	/** Get next sectionID for given section ID */
	int32 Montage_GetNextSectionID(UAnimMontage* Montage, int32 CurrentSectionID);

	/** Get Current Active Montage in this AnimInstance **/
	UAnimMontage * GetCurrentActiveMontage();

	/** Get Currently active montage instace **/
	FAnimMontageInstance* GetActiveMontageInstance();

    Relevant Properties on FAnimMontageInstance, accessed via above functions


    UPROPERTY()
    	float Position;
    
    	UPROPERTY()
    	float PlayRate;
    
    	UPROPERTY()
    	bool bPlaying;

Further Research

Check out all of

AnimInstance.h
AnimMontage.h

Enjoy!

:heart:

Rama

Thanks Rama. This will work. :wink: