Hello!
I am pretty new at unity and c# and struggling on how to use two (or more) separate audio clips on my GameObject.
I have a sort of “footsteps on grass” sound that is playing when:
" float orizzontale = Input.GetAxis(“Horizontal”);" is > or < than 0 and stop when it’s 0.
Now footsteps in the grass is working fine: It stops and it comes again … but when I jump I can’t hear sound.
I think the reason is that i put AUDIOSOURCE in pause or stop. How can I pause just a clip and not the whole Audiosource?
void SuoniPorco(float orizzontale) {
if (orizzontale < 0 && !suoni.isPlaying && !porcoInVolo || orizzontale > 0 && !suoni.isPlaying && !porcoInVolo) **//If my player is moving and is not jumping, then ...**
{
suoni.PlayOneShot(cammina); **// Play Sound Clip Until ....**
}
if (Mathf.Abs(orizzontale) < 0.001 || porcoInVolo) **//Player is not moving or he's jumping**
{
suoni.pause(); **//If so ... PAUSE this clip**
}
**// IF player Jumps ... then PLAY a JUMP sound**
if (porcoSalta) {
suoni.PlayOneShot(salto);
porcoSalta = false;
}
}