SFXEmitter still playing after volume set to 0?

Discussion in 'Programming' started by DaddelZeit, Sep 4, 2021.

  1. DaddelZeit

    DaddelZeit
    Expand Collapse

    Joined:
    Jul 17, 2019
    Messages:
    3,085
    I have a SFXEmitter I want to turn off through lua, however it still plays after setting the volume to 0.
    Since it stops when changing anything else manually through the world editor, I'm guessing there's something I have to call in order to update the Emitter.
    Here's my current code:
    Code:
    local function setRainSounds()
        local soundFXNormal = scenetree.findObject("Ambient_Sounds")
        if soundFXNormal then
            soundFXNormal.volume = 0.0
        end
    end
     
  2. angelo234

    angelo234
    Expand Collapse
    Junior Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    433
    Use the stop() to turn off the sound:

    Code:
    local function setRainSounds()
        local soundFXNormal = scenetree.findObject("Ambient_Sounds")
        if soundFXNormal then
            soundFXNormal:stop()
        end
    end
    If you want to turn it back on, use the play() function instead.
     
    • Like Like x 1
  3. DaddelZeit

    DaddelZeit
    Expand Collapse

    Joined:
    Jul 17, 2019
    Messages:
    3,085
    Thank you!
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice