Collision Sensor: propName

propName:
  • gets/sets the name of the property/material that the collision sensor looks for.

Type: 
  • string
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


################  Get the name of the property/material that the collision sensor looks for.

# 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"]

# get the name of the property/material
name = sen.propName 
 
Sample Code


################  Set the name of the property/material that the collision sensor looks for.

# import bge module
import bge

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

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

sen = cont.sensors["sensor"]

# Set the name of the property/material
# property/material name is enemy
sen.propName = "enemy"