Announcement

Collapse
No announcement yet.

question about the order of function execution in unreal

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    question about the order of function execution in unreal

    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?

    Thanks.


    Attached Files

    #2
    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.
    https://www.casualdistractiongames.com

    Comment


      #3
      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.

      Comment


        #4
        Originally posted by jmgold07 View Post
        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.
        That seems about right. Function1 triggers the Evt1-custom-event. But the delay inside Evt1 is ignored because the chain of execution starts with a function. So that causes Evt1-Print-String (event_after_delay) to get executed first before Function1-Print-String (after_event_called), which itself gets executed before Function2-Print-String (last). If this is unclear, try pasting a Delay into a Function...
        Last edited by EntrpriseCustomr; 07-04-2020, 04:51 AM.

        Comment


          #5
          Originally posted by jmgold07 View Post
          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.

          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".

          Comment


            #6
            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.

            Comment

            Working...
            X