Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | TheBadDev |
So, I’m working on add a main menu music on my new game Alien Evaders (On itch) and I’m coding the thing where I get the music added but it’s going to make someone go deaf on how loud it is and I edited the pitch slider on the inspector tab, but it would be very loud. So, after a couple of edge searches and I added some lines of code most importantly.
music.add_bus_effect(0, pitchShift)
this is where everything goes wrong the music still plays but game won’t show up and I get the error.
Invalid call. Nonexistent function ‘add_bus_effect’ in base ‘AudioStreamPlayer’
Here is my code for the main menu
extends CanvasLayer
var music: AudioStreamPlayer
var pitchShift: AudioEffectPitchShift
func _ready():
music = AudioStreamPlayer.new()
add_child(music)
music.stream = preload("res://song.mp3")
pitchShift = AudioEffectPitchShift.new()
pitchShift.pitch_scale = -25 # Reduce the pitch scale
music.add_bus_effect(pitchShift)
music.play()
func _on_restart_button_pressed():
music.stop()
get_tree().change_scene_to_file("res://world.tscn")
print("Start")