@@ -37,6 +37,17 @@ var _current_note = 0;
37
37
var _current_obstacle = 0 ;
38
38
var _current_event = 0 ;
39
39
40
+ # There's an interesting issue where the AudioStreamPlayer's playback_position
41
+ # doesn't immediately return to 0.0 after restarting the song_player. This
42
+ # causes issues with restarting a map because the process_physics routine will
43
+ # execute for a times and attempt to process the map up to the playback_position
44
+ # prior to the AudioStreamPlayer restart. This bug can presents itself as notes
45
+ # persisting between map restarts.
46
+ # To remidy this issue, this flag is set to true when the map is restarted. The
47
+ # process_physics routine won't begin processing the map until after the
48
+ # AudioStreamPlayer has reset it's playback_position to zero. This flag is set
49
+ # to false once the AudioStreamPlayer reset is detected.
50
+ var _audio_synced_after_restart = false
40
51
41
52
var _high_score = 0 ;
42
53
@@ -54,6 +65,7 @@ var cube_cuts_falloff = true
54
65
var max_cutted_cubes = 32
55
66
56
67
func restart_map ():
68
+ _audio_synced_after_restart = false
57
69
song_player .play (0.0 );
58
70
song_player .volume_db = 0.0 ;
59
71
_in_wall = false ;
@@ -80,9 +92,6 @@ func restart_map():
80
92
$ Track .remove_child (c );
81
93
c .queue_free ();
82
94
83
- for w in get_tree ().get_nodes_in_group ("wall" ):
84
- w .queue_free ()
85
-
86
95
$ MainMenu_OQ_UI2DCanvas .visible = false ;
87
96
$ Settings_canvas .visible = false ;
88
97
$ Online_library .visible = false ;
@@ -343,9 +352,14 @@ func _update_saber_end_variabless(dt):
343
352
func _physics_process (dt ):
344
353
if (vr .button_just_released (vr .BUTTON .ENTER )):
345
354
show_pause_menu ();
346
- # show_menu();
347
355
348
- if (song_player .playing ):
356
+ if song_player .playing and not _audio_synced_after_restart :
357
+ # 0.5 seconds is a pretty concervative number to use for the audio
358
+ # resync check. Having this duration be this long might only be an
359
+ # issue for maps that spawn notes extremely early into the song.
360
+ if song_player .get_playback_position () < 0.5 :
361
+ _audio_synced_after_restart = true ;
362
+ elif song_player .playing :
349
363
_process_map (dt );
350
364
_update_controller_movement_aabb (left_controller );
351
365
_update_controller_movement_aabb (right_controller );
0 commit comments