Collision sensor

Option(s) of the Collision sensor :

  • Pulse :
    • Disabled (default) : A pulse is sent when a collision occurs only while not being already in collision with another object. A negative pulse is sent only when there's no more collision with any objects.
    • Enable : Each additional collision sends a new positive pulse. A negative pulse is sent each time any collision comes to an end.
  • M/P : Toggle between using a Material or a Property for collision detection. (For material mode, leave blank to react to all materials)
  • Common options of all Sensors

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.hitObject : Returns the first object colliding with it that has the selected Material/Property . Returns "None" if none
  • sen.hitObjectList : Returns a list of the objects with the selected material/property colliding with the game object (see above Pulse option) . Returns an empty list [] if none
  • sen.propName : Get/set the name of the property/material
  • sen.useMaterial : Get/set if sensor is looking for a Material or a Property
  • sen.usePulseCollision : Get/set if sensor is using pulse collisions


Collision must be enabled on the game object : Properties menu » Physics tab » Physics » Physics Type » Static or Dynamic or Rigid Body or Soft Body

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License