I have a UI widget setup with a main image that doesn’t do anything until you press any key. Once a key is pressed a timeline runs and the menu opens. (Its a book and key press opens the book). Once the book is open I’d like a UI animation to play that would make the Play, Setting, Exit buttons appear. I’ve already built the animation to render correctly. I just can’t get the event to trigger.
Here is the image of the timeline event that would ideally trigger the animation. Its an a generic actor blue print. I’ve been reading about interfaces and was hoping that would trigger it but again i don’t know how to reference the Animation to get it push the info there using an interface.
One needs to be aware of the other. Since you have a widget, this needs to be stored somewhere that is accessible by your actor.
The simplest solution is to create a subsystem (likely derived from GameInstanceSubsystem) if you know C++. Then you can store a reference to your widget there and the subsystem is available to any code or blueprint at any time while the game is playing.
If you don’t know C++, then the easiest might be to just store an invisible Actor in the game where you add a Transient property for your widget. You can grab it using GetAllActorsByClass. So your widget would add itself to the Invisible Actor’s property. And your actor that receives the key press would grab the property when the Timeline is done (using GetAllActorsByClass).
Note that GetAllActorsByClass is a slow operation. So you may want to store a reference to the invisible actor in a property for reuse wherever you use it.
I find all games need a central repository for information sharing. I’m not sure why UE doesn’t have something a bit more well defined to handle this especially at the blueprint level. Then again, maybe I’m not aware of an existing solution.
So i setup an interface everything i was reading was saying this should be the easiest way. So as you can see in my actor blueprint i set up as follows.
Press any key my timeline runs opening the main menu book. At the end of that i have it grabbing all actors that are using my interface and looping through them to output to the interface action.
I noticed there’s an “Get All Widgets with Interface”. Give that a try.
BTW, these names are just the names of the base classes.
UserWidget derives from Widget that derives from Visual that derives from Object
UserWidget->Widget->Visual->Object
Actors on the other hand start at Character (these are the most derived aside from custom classes).
Character->Pawn->Actor->Object
So “Get All Actors with Interface” will grab all Characters, Pawns and Actors with said interface because they are all Actors (since it’s that very class or derived from it). But not Widgets because it is not derived from Actor.
As can be seen, it’s not just a matter of terms, but of hierarchy.
edit: Also, there’s absolutely nothing to feel stupid about. This stuff takes time to learn. I didn’t even know “Get All Widgets with Interface” existed. So your post got me to learn something new