giants-godot/singletons/Globals.gd

39 lines
910 B
GDScript

extends Node
var Bus = {
Master = "Master",
Ambiants = "Ambiants",
Sounds = "Sounds",
Music = "Music"
}
var target_position: Dictionary = create_empty_collision_dictionnary(Vector3.ZERO)
var process_3d_inputs: bool = true
func create_empty_collision_dictionnary(to: Vector3) -> Dictionary:
return {
"position": to,
"normal": null,
"collider_id": null,
"collider": null,
"shape": null,
"rid": null
}
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")