Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use await for Timer.timeout signal #403

Closed
tishin opened this issue Feb 19, 2024 · 0 comments · Fixed by #404
Closed

Unable to use await for Timer.timeout signal #403

tishin opened this issue Feb 19, 2024 · 0 comments · Fixed by #404

Comments

@tishin
Copy link
Contributor

tishin commented Feb 19, 2024

A simplified node example:

@Godot
class TimerNode: Node {
    
    let timer = Timer()
    
    override func _ready() {
        addChild(node: timer)
        
        timer.start()
        GD.print("started")
        
        Task {
            await timer.timeout.emitted
            GD.print("emitted")
        }
    }
    
}

Awaiting for timeout throws an error:

ERROR: Caller thread can't call this function in this node (/root/Timer/@Timer@2). Use call_deferred() or call_thread_group() instead.
at: connect (scene/main/node.cpp:3706)
Warning, error connecting to signal timeout: errInvalidParameter

And the second print does not happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant