I have a widget which I have already added to the viewport, I have another part of that widget that I dont want to always display, so I would use animation to move it out and in to the viewport. But the animation never plays except if I add it to the viewport which results in adding the widget twice to the viewport.
How can I play animation for an already displayed widget without displaying it twice?
I have a master widget (which I added to the viewport) where I have dragged in another widget, and that widget has two horizontal boxes, one is what I have displayed all the time, and the second is like a message, I only want that to be seen when something triggers it.
So the horizontal boxes are childs of the widget, how would I trigger the animation on the second?
ok so when you add the master widget to the viewport store it in a variable object reference.
Once you have done that you can access it much easier. Then maybe create a function in your master widget that controls the play of the animation. That way all the animation is handled inside the master widget, but you now have access to it from the main game wherever you have stored your object variable.
So if you called you master widget object variable “MasterWidget” and your play function inside that called “PlayAnimation”
in the level (or whever you stored the widget object ref) just GetMasterWidget, then drag off that and “PlayAnimation”
I cant create separate animation for a dragged in widget to the master, only for the whole widget, thats why I done it in that widget that I have dragged in.
That WBP_Timer is the dragged in widget, now its in the master widget that I display. I cant click on parts of it, so I cant animate parts of that widget, because its premade. Thats why I did the animation in that widget, because here in the master widget its a whole widget.
Ok, so I added the master widget inside the player controller, so all players get the widget displayed, and I made the widget a variable, and from that I should call its function?
And how can I trigger the child’s animation on the master widget?
Okay, so now I have made an event inside the child widget (because it has delay), and made another event in the master widget where I call the child widget’s event.
I call the master widget event in C++ gamestate because it is a BlueprintImplementableEvent UFUNCTION(), for some reason it still doesnt fire, I have tested it, calling the child event from Event Construct in master widget, and it worked just how I wanted it to work.
Why isnt it executing the animation when I call it from C++? (If I add a print string node in the child event, then it prints that out, but the animation is nowhere)
GameModeWidget = CreateWidget<UUW_GM_HideNSeek>(GetWorld(),GameModeWidgetClass);
GameModeWidget->ShowGamePhaseMessage(); //<-this is where I call it in C++
Unfortunately how this is called from c++ is not my forte, mainly deal with blueprint. Only thing i could say is make sure nothing is set to private anywhere. But if you are succesful calling it in blueprint theb c++ should fire ok especially as you say it has a print node in there which works. Sorry i cannot help you further. U less its in blueprint.