Sound Actuator Loop Bidirectional: attenuation

attenuation
  • sets/gets the rate that the sound falls off as the distance increases.
     
  • 0.0 = no fall off as distance increases
     
  • Sound Actuator name:  Rolloff

Type: 
  • float number

Range:

  • 0.00 to 5.00
Loop Bidirectional:
  • Plays the sound file from start to finish.  Then finish to start.  Over and over.
  • Positive Pulse:  Starts playing the sound file from the beginning.
  • Negative pulse:  Keeps playing the sound file until it reaches the end, then stops playing.
Sample Code


################  get the rate the sound falls off with distance

# import bge module
import bge

# get the controller
cont = bge.logic.getCurrentController()

# get the actuator attached to the controller
# my actuator is named Song

act = cont.actuators["Song"]

# get the attenuation
rate = act.attenuation
 
Sample Code


################  Set the rate the sound falls off with distance

# import bge module
import bge

# get the controller
cont = bge.logic.getCurrentController()

# get the actuator attached to the controller
# my actuator is named Song

act = cont.actuators["Song"]

# set the attenuation to 2.5
act.attenuation = 2.5