• Godot HelpAudio
  • [SOLVED]Correct Method To Load Sound Effect, Set its Volume, Then Play It - All In Script Code?

Hi,

We got music working, but are confused about sound effects. What is the correct method to load sound effects, set their volume, and then play them all in script code?

Let us know, thanks!

Jesse www.FallenAngelSoftware.com

Hi,

We got the sound effect playing now, but it repeats? How to disable repeat of playing sound effect?

Jesse

# "AudioCore.gd"
extends Node


var MusicVolume
var EffectsVolume


func _ready():

	MusicVolume = 1.0
	EffectsVolume = 1.0

	var music_player = AudioStreamPlayer.new()
	music_player.stream = load("res://media/music/TitleBGM.ogg")
	add_child(music_player)
	music_player.set_volume_db(linear2db(MusicVolume))
	music_player.play()

	var effect_player = AudioStreamPlayer.new()
	effect_player.stream = load("res://media/sound/Explosion.ogg")
	add_child(effect_player)
	effect_player.set_volume_db(linear2db(MusicVolume))
	effect_player.play() # Plays, but how to disable repeat?


	pass


func _process(delta):


	pass
2 years later