Why a widget animation won't play in UE5 through c++?

In a c++ widget that’s linked to a BP class, I decalred a new UWidgetAnimation that uses the Transient and BindWidgetAnim tags:

UPROPERTY(Transient, meta = (BindWidgetAnim))
UWidgetAnimation* Spinner;

Then, I created an animation in the BP class, it’s successfully bound to c++, but when I try to play the animation, it just won’t play - even though it is valid, and the log is even printed to the screen.

if (Spinner && Spinner->MovieScene)
{
UUserWidget::PlayAnimation(Spinner, 0.0f, 1, EUMGSequencePlayMode::Forward, 1.0f);
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Orange, FString(“Animation is
PLAYING!!”));
}

I tried calling this code at EventConstruct, Button events, and what not.
Also tried to go with the old method of storing all UWidgetAnimation variables in a TMap (without the Transient and meta = BindWidgetAnim tags), still with no luck.
For some reason none of it seems working for me!
What am I doing wrong?!

1 Like

This might sound stupid, but are you sure the animation has keyframes and isn’t empty? I haven’t managed to reproduce it myself and I have no idea why it doesn’t work for you, but this worked for me:


1 Like

I checked the source code and the animations are ticked in UUserWidget::TickActionsAndAnimation, which is called in NativeTick. This means TickFrequency has to be set to Auto for animations to work. Is NativeTick and Super::NativeTick called?

2 Likes

OMG that was it!
I only had to add a call to UUserWidget::TickActionsAndAnimation and parse InDeltaTime, and it works!
Thank you so so much!!!

I now realize that I only had to add a call to Super::NativeTick for the animations to work! Since TickActionsAndAnimation is called in UUserWidget.
No more drugs for me today!