No way I can make my PlayOneShoot work with the sounds. The only way I can make the sound work is if I use the audio on AudioSource ( Which I can use only one sound). I tried to check the volume, is not the case. I used Debug.Log to check if Stop sound is overcoming PlayOneSound (is not the case). I desactivated the collision Script to see if there is anything cause trouble (not the case). Tried different audios, checked if my Unity is without sound (no the case because if I use mainEngine on AudioSource component it works just fine. Any more Ideas on what I can try?? I will Skip this lesson for now since I have been breaking my head with this for days!
hehehe
You are starting the audio on every frame. it has no chance to start playing because you restart it on the next frame. Based on the Debug.Log
in the screenshot you have a misplaced scope. You have
if (Input.GetKey(KeyCode.UpArrow))
{
// do the stuff I'm not going to type out
}
else
{
Debug.Log("Audio Not playing");
audioSource.PlayOneShot(mainEngine, 1.0f);
}
So if you press up add the thrust and play the sound, and if you are not pressing up just play the sound
So it means that my Audio cannot be associated with Update? The Class I watched I basically copied the code, the code below was just added to see if anything else makes the sound play
else
{
Debug.Log(“Audio Not playing”);
audioSource.PlayOneShot(mainEngine, 1.0f);
}
I understood what you said about the sound trying to play but then comes another frame so it doesnt have a chance to play, but how to fix that? Removing the sound from Update Method? Sorry i am a noob, started to code no long
Actually, I was wrong. AudioSource.PlayOneShot()
is not going to cancel a clip that’s already playing.
I think the problem is the Pitch
on the AudioSource
. I just tested it and with a Pitch
below 0 nothing plays. Change it to 1 and try again
Maaaaan, you are a freaking genius!
You solved my problem, you are really a master problem solver!!
Love you man!!
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.