giants-godot/singletons/Globals.gd

26 lines
599 B
GDScript3
Raw Normal View History

2021-09-22 18:04:03 +02:00
extends Node
var Bus = {
Master = "Master",
Ambiants = "Ambiants",
Sounds = "Sounds",
Music = "Music"
}
func play_sound(sound: AudioStreamSample, bus: String, parent: Spatial = null):
if parent:
var stream = AudioStreamPlayer3D.new()
stream.transform = parent.transform
parent.add_child(stream)
stream.unit_size = 100
stream.bus = bus
stream.stream = sound
stream.play()
stream.connect("finished", stream, "queue_free")
else:
var stream = AudioStreamPlayer.new()
stream.bus = bus
stream.stream = sound
stream.play()
stream.connect("finished", stream, "queue_free")