Download

How to trigger event after closing a widget

Hello! Wondering if anyone could offer me a little help.

In a game I’m making, the player can pick up several books. Each book is an actor with a bit of text saved in a variable. When the user picks up the book, I create a UI widget from inside the book actor, and send the text to that widget to be displayed on screen. Up to this point everything is ok.

However, I’d like to trigger an animation on the book *after *the user finishes reading and closes the UI. Currently, the animation triggers almost immediately - i.e. while the widget is still open. Is there some way to detect within the book actor whether the widget has been closed? Or is there some kind of callback function I can run in the widget to signal the book actor to run its animation?

Thanks for any help with this! Been stuck on it for awhile now…

What I would do is feed in a reference to the book to the widget.

Then use that reference to call an event on the book with the animation when the “Done reading” button is pushed.

Event dispatchers are one of the most important things you can master in Unreal Engine. It takes time and there a few really good video tutorials that walk you through it. If you were to spend a single day mastering something I would recommend it to be Event Dispatchers, they are just that important.

Here’s a good start:
https://youtube.com/watch?v=sEcoWGrF1Hg