Add reload

This commit is contained in:
2023-08-04 15:50:02 -07:00
parent e396a34d1b
commit d28eb01c25
5 changed files with 37 additions and 8 deletions

View File

@@ -54,7 +54,7 @@ public partial class Gun : Node3D
private async Task Reload()
{
_reloading = true;
await ToSignal(GetTree().CreateTimer(0.3f), "timeout");
await ToSignal(GetTree().CreateTimer(0.5f), "timeout");
_reloading = false;
}

View File

@@ -2,8 +2,21 @@ using Godot;
public partial class SoundEffects : AudioStreamPlayer3D
{
private string _fireSfx = "res://Audio/SFX/gunshot.mp3";
private string _reloadSfx = "res://Audio/SFX/reload.mp3";
public void OnFireGun()
{
var audioStream = ResourceLoader.Load<AudioStream>(_fireSfx);
Stream = audioStream;
Play();
}
public void OnReload()
{
var audioStream = ResourceLoader.Load<AudioStream>(_reloadSfx);
Stream = audioStream;
Play();
}
}