Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | inesp |
I have the music in the singleton playing, but when I change the scene the music hangs (makes “trrutrrutrrutrrutrrutrrutrru”)
That shouldn’t happen. But without knowing your code that’s impossible to fix. Can you upload an example project? The fact that it’s making “trrutrrutrrutrrutrrutrrutrru” is sadly not telling anyone what you’re doing wrong there…
njamster | 2020-06-18 12:43
I do this in the singleton
**func start_music():**
# if a music is playing, remove it
if music_player != null:
music_player.stop()
# play the new song
music_player = play_sound_effect(current_music)
**func scene_changer(next_scene, avoid_load=false):**
times.append(["scene_changer", OS.get_time(), next_scene])
# this function controls how scenes are changed
if resumable_scenes.find(next_scene) > resumable_scenes.find(resume_scene):
resume_scene = next_scene
# save the changes to the game play
save_game()
if get_tree().get_current_scene().get_name() in ["Loading", "Earthquakes2", "House2"]:
avoid_load = true
if scenes_path[next_scene]["has_loading"] and not avoid_load:
scene_to_load = next_scene
if not get_tree().change_scene(scenes_path["Loading"]["path"]) == 0:
logger.error("It was not possible to change the scene")
else:
scene_to_load = ""
if not get_tree().change_scene(scenes_path[next_scene]["path"]) == 0:
logger.error("It was not possible to change the scene"
on this link you can hear the problem: https://photos.app.goo.gl/XtpADqHWmaxMnm177
inesp | 2020-06-19 22:27
When and how often is start_music
called? What does play_sound_effect
do? What happens during save_game
? The code you provided looks fine, so the problem likely stems from some of the parts you’ve omitted here. Of course it might also be a bug in the engine, I cannot rule that out completely.
njamster | 2020-06-20 10:27