Skip to content

Add wait_idle_frames() #675

@marcinn

Description

@marcinn

Versions

What versions of Godot do you want to use this feature in?
4.3+

The Feature

wait_idle_frames()

Currently wait_frame() is implemented top of a physics process, which is less or more related to IDLE frames handled in _process(). Physics frame ticks are also dependent on project settings (physics/common/physics_ticks_per_second, physics/common/max_physics_steps_per_frame and probably physics/common/physics_jitter_fix).

As a result, to wait for IDLE frame you don't know how much physics frames you must wait, so you're sticking with a wait_seconds(), slowing down your tests and praying that one IDLE frame will take less than one second.

The proposal is about adding awaiter for exact idle frames. When I want wait for a two IDLE frames, I should call:
await wait_idle_frames(2).

Possible implementation

 func wait_idle_frames(frames):                                                                                                                                        
     while frames > 0:                                                                                                                                                 
         await Engine.get_main_loop().process_frame                                                                                                                    
         frames -= 1

Thank you.


TBH: if not really needed, it would be better to implement awaiters on _process than _physics_process.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions