sound isn't so terrible

This commit is contained in:
Ian Woods 2026-06-28 20:55:12 -07:00
parent 95603a9a12
commit c5cba2dcd7
4 changed files with 16 additions and 6 deletions

View file

@ -20,6 +20,10 @@ namespace TD.Combat
[Tooltip("Sound played each time the coil discharges.")]
[SerializeField] private AudioClip fireClip;
[Tooltip("Pitch is randomized within this range each shot to avoid a mechanical loop.")]
[SerializeField] private float minPitch = 0.93f;
[SerializeField] private float maxPitch = 1.07f;
private TowerCombat combat;
private AudioSource audioSource;
@ -42,7 +46,11 @@ namespace TD.Combat
private void HandleAreaFired(Vector3[] positions)
{
if (fireClip != null)
audioSource.PlayOneShot(fireClip);
{
audioSource.pitch = Random.Range(minPitch, maxPitch);
audioSource.clip = fireClip;
audioSource.Play();
}
}
}
}