yield(get_tree(),"idle_frame") doubles the execution!

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By burstina

I tried yield(get_tree(),"idle_frame") in _ready() function and it seems to work fine: when yield execute, it resumes execution just the line after and process goes smoothy.


I tried yield(get_tree(),"idle_frame") in a throwaway function called in _process(delta) and it doesn’t work like that: each line of code between “yield” and end of function get executed twice.

Did it work as intended or is it a bug?

I’m using Godot 3.1 beta9


Cannot reproduce this in beta 9 on my machine. Can you share the code? Or try to print something

Dlean Jeans | 2019-03-01 04:26

:bust_in_silhouette: Reply From: burstina

I found out:
using yield() in _process() is troublesome because the script turn into a wait state, but application is still going to execute _process() the next frame time even if the wait state is still active.

I had only to build a bounduary around yielding function:

                 if !yielding:
			        yielding = true
			     	some ()
		            yielding = false