Audio Problems!

void ProcessInput()

{

    if (Input.GetKey(KeyCode.Space))

    {

        rb.AddRelativeForce(Vector3.up * thrust * Time.deltaTime);

        if (!SFX.isPlaying)

        {

            SFX.Play();

        }

        else

        {

            SFX.Stop();

        }

    }

}

This is what i wrote for audio. But my ausio is overlaying on top of each other and bugging out hard.

Please advise me on a fix for this

If you want multiple bits of audio playing at the same time, have a separate audio source for each item that you want overlaying instead of interrupting.

Oh no no

The thrust of the rocket has a single audio fine but there is some kind of stutter going on as if its overlaying on top of each other

I did exactly what Rick told but that audio file is driving me nuts :frowning:

file*

Ok,

Gotcha. If that’s the case, I think you have a logic error in your code.

I’d probably fix it like this:

if (Input.GetKey(KeyCode.Space))
{
    rb.AddRelativeForce(Vector3.up * thrust * Time.deltaTime);
    if (!SFX.isPlaying)
    {
        SFX.Play();
    }
}
else
{
    SFX.Stop();
}

and have the stop attached to whether the key is pressed, rather than stop the audio if the sound effect is playing.

So That ELSE statement is for the key press rather than the thrust sound

Thank you soo much. My problem has been fixed

Glad it helped.

Hi @Rustic_Dude,

Welcome to our community! :slight_smile:

Was MichaelP able to help you? Is the problem solved?


See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms