0 votes

Can you please tell what purpose of lines :

yield(get_tree(), "idle_frame")

I tried to comment these lines with symbol #. But not detected any visible difference in execution. If possible please give detailed description.

in example :

func _ready():
    viewport = get_node("Viewport")
    viewport_sprite = get_node("televizor")

    # Assign the sprite's texture to the viewport texture
    viewport.set_clear_mode(Viewport.CLEAR_MODE_ONLY_NEXT_FRAME)

    # Let two frames pass to make sure the screen was captured
    yield(get_tree(), "idle_frame")
    yield(get_tree(), "idle_frame")
    viewport_sprite.texture = viewport.get_texture()

    set_process(true)
in Engine by (20 points)

your godot version?

1 Answer

+1 vote

In this case, it seems that it tries to wait a couple of (idle) frames before assigning a viewport to a texture, looks like code of a version 3.0-, since 3.1 all problems with ViewportTexture were (apparently) solved and you do not even need code, only if working on split screen in 2D.

by (7,796 points)
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.

Categories