As the title suggests, I'd like a way to not directly call another function, but rather queue it for being called in the future (preferrably next frame)
Looking for a way to signal a funtion to be called on the next frame
- Best Answerset by retroshark
It sounds like what you want is the function "call_deferred".
https://docs.godotengine.org/en/stable/classes/class_object.html#class-object-method-call-deferred
Maybe call_deferred? https://docs.godotengine.org/en/stable/classes/class_object.html#class-object-method-call-deferred
Its not the next frame. But it is the end of the current frame which should be nearly as good.
Perfect! thanks for the answers
Haystack Marking your post as the best answer
I know this is a bit old, but since nobody mentioned this here... call_deferred does not wait until the next frame (as was stated to be the preference by the OP). Rather, it waits until "idle time", which can usually be thought of as the end of the current frame.
To actually wait until the next frame, you can use a zero-second timer, which in Godot 4.3 can be accomplished as follows:
# Do some stuff
await get_tree().create_timer(0).timeout
# Do some stuff on the next frame