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

BIN
Assets/_Project/Audio/tesla_tower.ogg (Stored with Git LFS)

Binary file not shown.

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: ac71e042fc717a9c496b76afa7803ddf guid: a0b5d0b15de667604b825f12d39b05a8
AudioImporter: AudioImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 8 serializedVersion: 8

View file

@ -237,7 +237,7 @@ AudioSource:
m_audioClip: {fileID: 0} m_audioClip: {fileID: 0}
m_Resource: {fileID: 0} m_Resource: {fileID: 0}
m_PlayOnAwake: 0 m_PlayOnAwake: 0
m_Volume: 1 m_Volume: 0.5
m_Pitch: 1 m_Pitch: 1
Loop: 0 Loop: 0
Mute: 0 Mute: 0
@ -333,7 +333,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: db643146344a08a639133638e4746a33, type: 3} m_Script: {fileID: 11500000, guid: db643146344a08a639133638e4746a33, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: Assembly-CSharp::TD.Combat.TeslaTowerFireSound m_EditorClassIdentifier: Assembly-CSharp::TD.Combat.TeslaTowerFireSound
fireClip: {fileID: 8300000, guid: ac71e042fc717a9c496b76afa7803ddf, type: 3} fireClip: {fileID: 8300000, guid: a0b5d0b15de667604b825f12d39b05a8, type: 3}
minPitch: 0.92
maxPitch: 1.07
--- !u!1 &7101790219931971190 --- !u!1 &7101790219931971190
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View file

@ -20,6 +20,10 @@ namespace TD.Combat
[Tooltip("Sound played each time the coil discharges.")] [Tooltip("Sound played each time the coil discharges.")]
[SerializeField] private AudioClip fireClip; [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 TowerCombat combat;
private AudioSource audioSource; private AudioSource audioSource;
@ -42,7 +46,11 @@ namespace TD.Combat
private void HandleAreaFired(Vector3[] positions) private void HandleAreaFired(Vector3[] positions)
{ {
if (fireClip != null) if (fireClip != null)
audioSource.PlayOneShot(fireClip); {
audioSource.pitch = Random.Range(minPitch, maxPitch);
audioSource.clip = fireClip;
audioSource.Play();
}
} }
} }
} }