Hi. I’m a bit unsure re: the order of function execution in unreal, specifically when an event is fired within one of the functions.
In img1 there is function 1 and function 2 off event beginplay.
In img2 there is an evt fired from within function 1 and then a print string.
I thought the entire event would complete execution (including the delay) before returning to function 1 and printing the string after event called.
I thought the order of print strings would be:
event called -> event_after_delay -> after_event_called -> last
But when running it was
event called -> after_event_called -> event_after_delay -> last
So basically function one wasn’t waiting for event to be completed before finishing.
Does that mean events are asynchronous?
And I haven’t placed return nodes in the functions because nothing is returned at this stage. Should I be putting return nodes there anyway?
Anything after delay only executes after the delay.
Think of the delay as schedule this stuff to occur after the delay.
There is no "waiting " for the event with a delay to finish. Once the delay has scheduled it is done.
Thanks but the issue I am unsure about is the print string in function 1 “after event called” is being executed before the event has finished.
I thought what might happen is that the whole event would execute, including the delay, and only then would the print string in function 1 be called.
Think about it as if it was not a call to a function, but start of a new, separate thread executing the event code. It is not “start and wait till the execution ends” but just “start”.
Delays IN functions only apply to said functions code. Inline delays affect the sequence of execution down the chain.
e.g. Function1 → Delay → Function2 … this results in a delay (wait) before Function2 is executed.