Add reload
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user