Force function to finish first

So I´m currently getting some errors and the only thing that would explain this is that the function gets called, but the execution pin instantly continues without waiting the function to be finished… Or am I missing something here? Do I really have to use event dispatchers so I can be sure the function has finished?

Are you sure the function isn’t finishing before execution continues? Everything that runs on the main game thread gets processed in a straightforward and predictable order.

Is it possible your function is spawning worker threads somehow? Is it using operating system libraries to modify files, which may, in turn, be doing something with multi-threading?

What exactly does that Cleanup Folder function do? Maybe with more information, we can better help you identify the problem.

It’s because that’s not a function, it’s an event. A function is denoted by an “f” instead of an arrow.

When an event is triggered the event calculates seperate from the event chain that triggered it. It does not need to be completed for the original event chain to continue down its path. If you need calculations to finish before moving on, you either use a function, an event for moving on or a variable.

So in this case, end the execution event at Cleanup Folder. Add an event called “Continue” for example and plug that into the first branch in “Geometry”. At the end of Cleanup Folder add a call to that event.

Here’s a visual representation of that:

1 Like

I guess this must be the problem. I´m working with the asset regestry and rename files inside of this function. Since it is used in the editor, not at runtime it is reallý difficult to debug. Thank you for pointing me in the right direction!

Actually it was a function. But you pointed me in the right direction here. If a function doesn´t have an output the “f” disappears and it is handeled as an event. I added an empty output to my function and now it gets executed first. I was never aware of this.

A return node should serve the exact same purpose. Either way, you have options.