Random sensor

In some cases you want your game to trigger events randomly. This sensor will help you. Sends random pulses to the connected controller(s) . One positive pulse is immediately followed by a negative pulse

Option(s) of the Random sensor :

Python :

# import bge module
import bge
# get the controller
cont = bge.logic.getCurrentController()
# get the sensor attached to the controller
# my sensor is named Trigger
sen = cont.sensors["Trigger"]
  • sen.seed : Get/set the initial Seed of the generator ( integer )
  • sen.lastDraw : Returns the last random number generated ( integer )
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License