Collision Sensor: useMaterial

useMaterial
  • gets/sets if sensor is looking for a Material or a Property.

Type: 
  • boolean

Values:

  • 1 = True = Looking for a Material
     
  • 0 = False = Looking for a Property
Collision Sensor:
  • Leaving the Material/Property blank will cause the Collision Sensor to react to collisions with any game objects no matter what Material/Property they may have (this includes objects that don't have any Materials and/or Properties).
     
  • A collision with an object having the material/property sends a positive pulse to the connected controller(s) only if the game object isn't already touching an object with the material/property.
  • Continuously touching any game object with the material/property:  No pulses are sent to the connected controller(s).
  • Removing (no longer touching) all game objects with the material/property:  One negative pulse is sent to the connected controller(s).
Sample Code


################  Collision sensor looking for a material or a property?

# import bge module
import bge

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

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

sen = cont.sensors["Explode"]

# looking for a material or a property?
status = sen.useMaterial 
 
Sample Code


################  Set collision sensor to look for a property

# import bge module
import bge

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

# get the sensor attached to the controller
# sensor is named Explode

sen = cont.sensors["Explode"]

# set collision sensor to look for a property
sen.useMaterial = False