Obtaining a UWidgetAnimation to play animation

Hi. I am using 4.7.6. I have loaded a blueprint widget in C++ and added it to the viewport successfully. I am now trying to play an animation, but I cannot figure out how to get a reference to a UWidgetAnimation that I have created in the blueprint through the editor…

In UserWidget.h I am wanting to call the function defined below:

UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category="User Interface|Animation")
	void PlayAnimation(const UWidgetAnimation* InAnimation, float StartAtTime = 0.0f, int32 NumLoopsToPlay = 1);

Hi minderaser,

please check my answer to your question on the forum : https://forums.unrealengine.com/showthread.php?74248-Calling-UMG-Blueprint-animation-from-C

Let me know in case I didn’t understand your question!

Hi, thanks a bunch! So this required creating a custom class of UUserWidget to expose the animation variable. Then I set this class as the parent of my blueprint. Then in my pawn cpp file where I instantiate the blueprint, I changed the UUserWidget types to my custom class. This did allow me to then call PlayAnimation with the animation reference and it worked :slight_smile:

Glad it helped!

hello
i have same problem.
Could you tell me some more information or Images or Codes?
Thanks

Hi,

What problem are you encountering? Anyway, I’ve posted on the forum page as well, give it a look to see if now my comment is helpful.

Cheers

Dear Daniele Faggion, thanks a lot! I thought about this idea extending UUserWidget, but I thought that’s too much. I’m glad I found someone who did this and this worked. Thanks!

Hello in your answer you wrote this - (make sure Context Sensitive is not checked if this doesn’t come up in the search results) how and where to install Context Sensitive to the menu you can see the animation?