Godot Version
v4.3.stable.official [77dcf97d8]
Question
Hi there! I’m currently building the audio system for a gamejam entry, and seemed like a great opportunity to test the AudioStreamInteractive resource for AudioStreamPlayer.
I have set a music controller on autoload, and set some basic functions to control the playback and call whichever track I need based on clip_name. I also edited transitions (I presume) accordingly.
So “zone_0” and “zone_1” can both transition to “minigame”, in the actual minigame the track loops till you win/lose and then it should switch back to the previous zone clip.
I wanted to store the previous clip name in a variable, but through the official documentation I was unable to find a method to get the current playing clip’s name or clip_id. I am not super well-versed in reading through doc and implementing it correctly to suit my needs, so I am grateful if anyone knows how to solve this in particular.
extends Node2D
@onready var music_interactive_player := $Loop
@onready var playback: AudioStreamPlaybackInteractive = music_interactive_player.get_stream_playback()
@onready var previous_clip
func play_loop() -> void:
music_interactive_player.stream_paused = false
func pause_loop() -> void:
music_interactive_player.stream_paused = true
func stop_loop() -> void:
music_interactive_player.stop()
func play_music(clip: StringName) -> void:
playback.switch_to_clip_by_name(clip)
func play_music_minigame() -> void:
playback.switch_to_clip_by_name("minigame")
``