Is there a way to wait 1 frame on the screen with yield() ?

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

Im trying to stop the execution of a function for 1 frame. But my game is updating a lot faster than my screen, so sometimes if I change something before yield(get_tree(), “idle_frame”) and then change it back after, it doesnt show up. My game updates arround 1000 times/sec.

Basically I want Unitys: yield return new WaitForEndOfFrame();

Thanks in advance :slight_smile:

Yield will stop the process for a frame and requires resume to continue. Are you resuming?

happycamper | 2018-06-02 03:46

Know it’s not the same technically, but maybe just yield(get_tree(), "physics_frame"). Since practically it would fulfill most use cases I think. Don’t think there is any way to do what you want directly, there is no api to get screen refresh rate currently…

kubecz3k | 2018-06-03 12:47

:bust_in_silhouette: Reply From: gnumaru

maybe

yield(VisualServer, 'frame_pre_draw')

or

yield(VisualServer, 'frame_post_draw')