Jump from one function to the middle of another function

So, I’m working on a text based adventure thing, entirely in UMG.

Now, all my levels are basically functions. Each function contains the text for the “level” and the available options for the player. Whenever the player inputs the correct set of buzzwords, it goes to the next function (level).

In the event graph I have the Event Construct event, which runs my first level. I also have an OnTextCommitted event which sets the player input to a variable. The Action function scans the input and compares it to the available buzzwords inside each level.

Now, My problem is having the level “update” when I input the text. Right now, the level loads first, and if I input any text nothing happens. So I need something to help me fire the branches of the level after the Action function in the event graph has been fired. So I want to kinda jump from the end of one function to the middle of another function.

Can this be done? I know a little about event dispatchers, which seem to be the thing I need here, but I cannot get them to work. I cannot call custom events inside a function.

Or am I going about this the wrong way? Should I use macros instead? Or an entirely new widget for every level?

Any help will be appreciated. Thank you.

Hello PSyCHoHaMSTeRza,

I can tell you that it’s not possible to call a function part way through the logic. It’s also not possible to use events inside of a function.

A new widget per level would probably be the best idea.

You could also consider, if you still want to use functions, using the branching logic to your advantage. If there aren’t many of these instances or you don’t mind setting it up for each one of them, you could always have the function expecting to be entered with the intention of skipping part of it. You could give it a certain boolean based off what happened before entering the function and set up branches to skip past the logic that you wish to skip. That way would be much more complicated and much more work I’m sure.

Hope this helps!