Game Object: sensors

sensors
  • Returns a list of the sensors attached to the game object.

Return Type:

  • list [  SCA_ISensor ]
sensors[ "sensor_name"]
  • Returns a named sensor attached to the game object.

Return Type:

  • SCA_ISensor
Sample Code

################## get a list of the sensors attached to the game object
 
# import bge
import bge

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

# get object that controller is attached to
obj = cont.owner

# get sensor list
senList = obj.sensors

Sample Code

################## get a named sensor attached to the game object
 
# import bge
import bge

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

# get object that controller is attached to
obj = cont.owner

# get sensor named Jump
sen = obj.sensors["Jump"]