I’m trying to get a sound effect to play when the player swings a sword. Following a Brackeys tutorial, I got an audio manager set up. When I swung the sword, the console reports that the proper functions were called and the sound was played, yet I didn’t hear anything. The volume is maxed, it’s set to 2d. I did everything I could find. So I did some investigating and recorded the game audio in audacity. Turning up the audio, I found out it was, in fact, playing sound every time I swung the sword, but it was a weird clicking sound, as if the audio stopped the second it got played. I have no idea why this is happening.
I dont have alot of experience with sound stuff, but just to ask the obvious. Have you tried playing the sound clip somewhere else like say Windows Media Player to see if the sound file is working properly? Also have you tried downloading a different sound effect from somewhere like opengameart.org and trying that file to see if that one works?
u have 3 function for playing sound in unity
1- playing sound on awake without scripting from “play on awake” bool from audio source it self
2- AudioSource.Play(); which could be useful if playing sound just one or each period
3-ِfinally AudioSource.PlayOneShot(audioClipHere); this could be used for playing sound so fast like shooting weapons or something
now u have working sounds but it looks terrible when playing a lot so u can fix this using this simple line which randomly select pitch value
if it didn’t played at all go to edit/projectSetting/Audio/Disable Unity Audio make it false hope this works
public float factor = 0.2f;
public AudioSource audioSource;
public AudioClip clip;
private void Update()
//or use this AudioSource.PlayOneShot(clip, volume Value Here);
float audioPitch = Random.Range(Time.timeScale, Time.timeScale + factor);
audioSource.pitch = audioPitch;