0 votes

Please have a look at my teleporter code:

func _process(delta: float) -> void:
    if (player.transform.origin-transform.origin).length_squared()<20:
        if not $AudioStreamPlayer.playing:

notice the commented #yield, if i left it it apparently hangs. What I've tried is to play the sound and then when finished I wan to to change scene. I think issue can be related with having the yield in the process, and had call to set_process(false) but not sure, not sure how coroutine works in this case

in Engine by (36 points)

I tried to replicate your setup but it works fine (Godot 3.5.1), have you changed any of the properties of the AudioStreamPlayer or tried with a different audio file / stream? And does it crash if you connect the finished signal to a separate function and run the scene change there?

1 Answer

+1 vote
Best answer

Hehe it is beacause You yield every frame when the music is playing, so when "finished" is emitted, it only unyields one stack, while process still awaits millions of them byt that point :)

You can just indent your yield and change_scene one tab to the right to fix it

by (8,099 points)
selected by
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 Frequently asked questions and 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 [email protected] with your username.