Blueprint Async Function?

Is it possible yet to create an Async Function in a Blueprint?

functions are sync, and I don’t think Epic will change that in the near Future… that’s the reason you can’t use delays in functions.

CustomEvents are async. since you can’t return a value from an event, you need a Storage Variable that holds that data for you and can be read via a ref

1 Like

Have you tried extending UBlueprintAsyncActionBase?

(edit)
Here’s an example implementation that I like. It shows how a sequence of steps can be accomplished in a single async call and results in a simple delegate broadcast at the end.
AsyncAction_ExperienceReady.h
AsyncAction_ExperienceReady.cpp
image

1 Like

I do basically this, but firing off an Event Dispatcher at the end so that other events can subscribe to it.

Events are not sync even if they run on the game thread, async simply means that the function is not blocking the execution which events don’t do. What you are referring to is multithreading which is a different topic.

1 Like

Blocking the execution of what? I don’t get it.

Blocking the game thread. While Events are waiting to proceed other functions or events can happen (Async).

1 Like

Makes sense… Thanks I guess

No it doesn’t.

You can’t have two things happen on the same thread and have one not block the execution of the other. This is literally the antithesis of what a thread is.

Events ARE synchronous by default, otherwise they’d get the little clock on the top right of their rectangle. A common misconception seems to be that events somehow immediately spawn a new thread automatically, that’s just not the case. And for most usecases, this would be incredibly wasteful.

However: events, contrary to functions (at least the vanilla type), do allow asynchronous nodes to be used during their execution. And yes, in that specific case, anything after the async node will happen later. Even with a delay of 0ms, things will get processed outside of the current stack.

ClockworkOcean demonstrates this in a very simple way here: Are Events Synchronous or Asynchronous?

Do 8000 events modifying a single file, and it will work prefectly. Introduce a delay, and it “all goes out the window”. That’s because they are only async under specific circumstances.

1 Like