Play action after sound is loaded?

Hi everyone

I am now doing some actions for my game character for a ‘finish move’ after her dance. And i want a function that:

  • loads a sound track
  • when its loaded, it will play itself and the ‘happy yeeying action’ of my game character

The sound should be only played once. ( the script is connected to an Always with no pulse enabled )
The script now just makes the girl doing her yeeying action.

I made something like this but it doesnt really work. Thank you in advance for your help.


from bge import logic
import aud


def main():
    
    cont= logic.getCurrentController()
    own = cont.owner


    p_1 = logic.expandPath("\\sounds/endlevel.ogg")
    
    end = aud.Factory.file(p_1)
    
    name = "finish"
    start = 0
    end = 1000 
    layer = 0
    priority = 0
    blendin = 0
    mode = logic.KX_ACTION_MODE_PLAY
    layerWeight = 0.0
    ipoFlags = 1
    speed = 2.33


    own.playAction(name, start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)        
main()        

i guess this works fine. Tested _(^.^)/


from bge import logic
import aud


def main():
    
    cont= logic.getCurrentController()
    own = cont.owner


    
    name = "finish"
    start = 0
    end = 1000
    layer = 0
    priority = 0
    blendin = 0
    mode = logic.KX_ACTION_MODE_PLAY
    layerWeight = 0.0
    ipoFlags = 1
    speed = 2.33
    
    act = cont.actuators["end"]
    res = cont.actuators["res"]


    
    own.playAction(name, start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)
    own['frame'] = int(own.getActionFrame())        
    act.startSound()     
    own['time'] = act.time
    if own['time'] >= 4:  
        cont.activate(res)// state change
main()