Sensor Logic Brick: triggered

triggered
  • Returns if the sensor has triggered the controller.

Type: 
  • boolean

Values:

  • 1 = True = the sensor triggered the controller
  • 0 = False = the sensor didn't trigger the controller
Sample Code


################  find out if the sensor triggered the controller

# import bge module
import bge

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

# get the sensor attached to the controller
# my sensor is named Sensor_1

sen = cont.sensors["Sensor_1"]

# find out if the sensor triggered the controller
status = sen.triggered