Synchronous <suspends> Functions in Verse?

Is there a way to call a function without waiting for it to finish to continue?
Like a custom event in blueprints for example.

I need different tasks that all Sleep() for different reasons to happen simultaneously.
Thanks!

Yup. Use spawn

OnBegin<override>()<suspends>:void=
    Print("Log A")
    spawn{MyAsyncFunc(1.0)}
    spawn{MyAsyncFunc(2.0)}
    spawn{MyAsyncFunc(3.0)}
    Print("LogB")

MyAsyncFunc(SleepTime : float)<suspends> : void=
    Sleep(SleepTime)
    Print("Just waited for {SleepTime}")

This is untested, but I use these frequently.

5 Likes

Thank you so much! Worked perfectly :slight_smile: