0
$\begingroup$

I'm using a Blender 2.74 and am trying to pack external audio data into a .blend file. I am using Windows 7. If I try run my game on other another computer, everything but the audio seems okay.

Here is the audio script:

import aud

def main():

    cont = bge.logic.getCurrentController()
    own = cont.owner
    scene = bge.logic.getCurrentScene()
    gunspawn = scene.objects[own.name]

    # sensors
    Message = cont.sensors['Message']


    #sound of glock shoot
    sound = aud.Factory.file("C:/MakeHumanZip/project_last_back/sounds/glockshoot.ogg")

When I pack the external data into the .blend the audio only works on my machine. The audio doesn't work on other Windows 7 machines and the scripts eventually crash.

Can anyone help me with solution?

$\endgroup$
0
$\begingroup$

Referring to a file in a python script doesn't tell blender that it is using an external file, so it isn't included when packing external files.

You can add a sound strip to the Video Sequence Editor or you could add a speaker in the 3D scene and open the sound file with that. Both of these methods allow blender to pack the audio file into the blend and I expect that both will be included when exporting to the game engine runtime.

An even better approach would be to use a sound actuator and open the sound file with that, which allows it to be packed. You can then use the actuator to play the sound or access other properties with a python script, you can also use sensors to play the sound without the script.

cont = bge.logic.getCurrentController()
actu = cont.actuators['Sound']
cont.activate(actu)
$\endgroup$
  • $\begingroup$ i have more o 10 scripts for transform all to logic bricks is very complicated now. i need try solution with path in to the script but need work without errors the error is cant load aud file in all scripts only in other computer in my work fine. $\endgroup$ – user40596 Jun 24 '17 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.