Hi!!! I’m having a problem with a dialogue that I was trying to make a function in the Widget to set a text, prepare an animation and then add it to viewport and after the time has passed it removes it.
I have this .cpp of the DialogueWidget:
void UDialogueWidget::SetDialogueTextAndShow(FText text, float time)
{
if (!IsInViewport()) {
_dialogueText->SetText(text);
PlayAnimation(_blend, 0.f, 1, EUMGSequencePlayMode::Forward, 1.f);
PlayAnimation(_blend, time - 0.8f, 1, EUMGSequencePlayMode::Reverse, 1.f);
AddToViewport();
FTimerHandle dialogueTimerHandle;
GetWorld()->GetTimerManager().SetTimer(dialogueTimerHandle, [this]() {
RemoveFromParent();
}, time, false);
}
}
And this code in the .h:
UCLASS()
class SOPHIASFAULT_API UDialogueWidget : public UUserWidget
{
GENERATED_BODY()
public:
UPROPERTY(meta = (BindWidget), BlueprintReadWrite)
class UTextBlock* _dialogueText;
UPROPERTY(Transient, meta = (BindWidgetAnim), BlueprintReadWrite)
class UWidgetAnimation* _blend;
void SetDialogueTextAndShow(FText text, float time);
};
It doesn’t play any animation with this code.
I had another code that worked the FadeIn but not the FadeOut (it was the same code but instead of having just one _blend I had a _blendIn and _blendOut (I modified the Widget when I made the changes because it didn’t compile and because I didn’t need the _blendOut if it was the same that the _blendIn)).
If anyone can help me would be really apreciated