I’ve been expirimenting a bit with positional sound. Using the audio3d manager, as described here, I used the following code to mount a footstep sound to my player model:
audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], camera)
SOUNDPATH = ConfigVariableString("soundpath","").getValue()
runSound = audio3d.loadSfx(SOUNDPATH + 'run.wav')
walkSound = audio3d.loadSfx(SOUNDPATH + 'walk.wav')
audio3d.attachSoundToObject( runSound, self.actor)
audio3d.attachSoundToObject( walkSound, self.actor)
self.runInterval = SoundInterval(runSound, volume=1.0, name='play_' + "run")
self.walkInterval = SoundInterval(walkSound, volume=1.0, name='play_' + "walk")
However, when I actually use it, using the code below, the sound changes in a strange way when I use my chasecam. Instead of being globally the same at every moment, The sounds get louder when I walk in the global direction of where the player spawned and dies out when I walk the other way.
if ((self.keyMap["forward"]!=0) or (self.keyMap["backward"]!=0) or (self.keyMap["left"]!=0) or (self.keyMap["right"]!=0)):
if self.isMoving is False:
self.actor.loop(self.moveAnim)
if self.moveAnim == "walk":
self.walkInterval.loop()
self.runInterval.finish()
else:
self.walkInterval.finish()
self.runInterval.loop()
self.isMoving = True
else:
if self.isMoving:
self.actor.stop()
self.actor.loop("breathe")
self.walkInterval.finish()
self.runInterval.finish()
self.isMoving = False
It looks a bit like te source of the audio is not connected to the player or something. Am I missing something?