+2 votes

I can't seem to understand how to use the Yield function. I've tried following the docs but they just seem to confuse me even more. Nothing seem to work when following the examples in the Docs :(.. can someone please explain with some useful examples. Possibly using standard and signals/callbacks. I've also posted code sample of what i'm trying to accomplish.

  var test = null

func myFunc():
test = TriggerFX()

func TriggerFX():
in Engine by (274 points)
edited by

Your code is wrong in many ways that, to me it's not clear what you are trying to do. Try explaining it with words with a self-contained (pseudo-)code maybe.

Check the docs also (which explicitly mentions that it is the function that yields returns the function state, on which you can call resume, not the other way around).

Also, in case you're going to use it with signals, current implementation of yield doesn't work as advertised in the docs: you can yield only from a top-level function. See this issue for details.

OK. I think I'm starting to get the hang of how things run. Is GDScript synchronous or asynchronous when it comes to execution of methods? I'm coming from a C#/JavaScript background so some things are a bit different dealing with GDScript.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.