How can i control the volume of my game using only python script. No actuator involve
When we create a sound with the factory I think we can keep a reference to it, and adjust it later on the fly using the stored original reference (I have not tried)
if the upbge team starts to figures out that newcomers/newbies cannot read the python API documentation , maybe we wouldn’t have to answer those same questions forever …
@Dark_Ice I recommend you to have a look on this restored good old no pretentious manual
http://bgepython.tutorialsforblender3d.com/SoundActuator/LoopBidirectional/volume
import bge
import aud
from bge import logic
scene = bge.logic.getCurrentScene()
cont = bge.logic.getCurrentController()
plr = cont.owner
step_sound = aud.Factory.file(bge.logic.expandPath("//sounds/steps/step1.ogg"))
son1 = plr.actuators['sound1']
son1.sound = step_sound
son1.volume = 0.8
Edit : Well, i see that you need to control whole game volume… Not sure, but maybe this is your OS business . In all cases, you can see above that you can use python to parameter your logic bricks. This is my favorite hybrid approach in BGE
I made this a while back for a friend.
import os, bge, aud
os.system("cls")
print("Blender Game Engine Started")
PATH_SFX = bge.logic.expandPath(str("//Audio/Voice.mp3"))
VAR_VOLUME = 0.1
def main(self):
# Play sound + set volume
SFX = aud.Device().play(aud.Sound(PATH_SFX).volume(VAR_VOLUME))
# Loop sound
SFX.loop_count = -1
Blend
UPBGE_03_AUD_Volume.zip (123.0 KB)
You can set the overall volume of the Device:
import bge
import aud
device = aud.Device()
device.volume = 1
Thanks but i figured that out a long time ago on my own. Yeah that’s what i was looking for but i did it by myself