Blueprint equivalent of async/await?

So in my game I need to be able to execute a variety of actions that take more than one frame, in sequence, one after another. For example, translating/rotating actors over time, playing animations, etc. I’m finding that it quickly turns into a mess of event spaghetti that is difficult to follow.

Say I want to execute some chain of actions, like A > B > A > C from my blueprint. If A is handled by some other blueprint, maybe I’d add an Event Dispatcher called CompletedA, and bind to that. But then I need to keep track of whether to resume execution of the original chain from the first call to A (next action is B) or the second call (next action is C). That alone isn’t too bad, but it adds up.

I might be a bit spoiled by C#, where you can just do something like this in a single method and the compiler will generate the state machine for you.

await A();
await B();
await A();
await C();

Any ideas?

I don’t completely understand what you want, but it might be a timeline and a lerp node.

Set the timeline flaot value going from 0 to 1 over your specified length, wire the float into the alpha node in a lerp node, and it will lerp between rotations, positions, scale, etc.

Unfortunately there is no such notion in UE4. In C# you need to define the methods with async on them which says that they are some sort of parallel task. In unreal almost everything is parallel and there is no notasync notion. You will need to frame it like you would with Manual Reset Events in C# as you described above.

If you are rotating something over time though as you have in your example above you could/would use a timeline node in UE4 which can help with that.

Also, depending on what you’re trying to do the Sequence or MultiGate node might be helpful. Take a look at some of flow control tools they give you in BPs: https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/FlowControl/index.html

The real answer to your question is, it’s situational. Sometimes you want to do what you described above, sometimes flow control can solve the problem, sometimes inverting the control can fix the issue, etc. If you’re a C# dev then you are going to need to change how you think about software architecture for a game. Game engines work differently than traditional desktop/web applications. I ran into the same issue when I started because I was applying traditional software dev patterns to games and it go over well. This might also be useful: http://gameprogrammingpatterns.com/