public override void _Ready() { _audioNode = GetNode <AudioStreamPlayer3D>("Audio_Stream_Player"); _audioNode.Connect("finished", this, nameof(SoundFinished)); _audioNode.Stop(); _globals = GetNode <Globals>("/root/Globals"); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { // Audio resources _audioPistolShot = ResourceLoader.Load <AudioStream>("res://assets/audio/sounds/weapons/gun_revolver_pistol_shot_04.wav"); _audioGunCock = ResourceLoader.Load <AudioStream>("res://assets/audio/sounds/weapons/GUN_MP5K_Cocked_Full_Action_02.wav"); _audioRifleShot = ResourceLoader.Load <AudioStream>("res://assets/audio/sounds/weapons/gun_rifle_sniper_shot_01.wav"); _explosionSound = ResourceLoader.Load <AudioStream>("res://assets/audio/sounds/weapons/explosion_large_no_tail_03.wav"); // Nodes _audioNodeGlobal = GetNode <AudioStreamPlayer>("Audio_Stream_Player"); _audioNodeLocal = GetNode <AudioStreamPlayer3D>("Audio_Stream_Player_3D"); _globals = GetNode <Globals>("/root/Globals"); // Setup _audioNodeGlobal.Connect("finished", this, "DestroySelfGlobal"); _audioNodeGlobal.Stop(); _audioNodeGlobal.MixTarget = AudioStreamPlayer.MixTargetEnum.Surround; _audioNodeLocal.Connect("finished", this, "DestroySelf3D"); _audioNodeLocal.Stop(); _audioNodeLocal.AttenuationFilterDb = -0.1f; _audioNodeLocal.MaxDb = 50; _audioNodeLocal.AttenuationFilterCutoffHz = 10000; // Attributes _shouldLoop = false; _globals = GetNode <Globals>("/root/Globals"); }