+10 votes

The Godot 3.1 documentation tells us we should use call_deferred() for :
. disabling collisionshapes (Godot doc)
. switching scenes (Godot doc)
. (probably a bunch of other things)

... because :
. the collision engine might be busy processing things
. the scene code might still be doing stuff
. (???)

So : should we use call_deferred() everywhere instead of just calling the method ? What are the rules ???

Edit : maybe I should rephrase my question a bit ... : When is NOT using call_deferred() going to cause problems in my exported game (for pc) ?

in Engine by (101 points)
edited by

I know for disabled a collisionshape you do this:
set_deferred("disabled",true)

Thanks, Thoma !
Do you know more about when one should use 'deferred', and when one can just call the method itself ?

It is a bit confusing to me : if 'deferred' is 'the safe way to do it', then ... why is this not always happening 'behind the scenes' ?

No but this video can help you
Tutorial about deferred

Thanks ! I'll take a look ...


Seems like an interesting series to watch. Not quite the info I'm looking for, but definitely interesting !

+1'd this - after upgrading to 3.1 I've had to use calldeferred in a lot of my collision logic, which has somewhat muddied my code, e.g. using calldeferred('magic-string') in place of direct calls.

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 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 webmaster@godotengine.org with your username.