Ray Sensor: hitPosition

hitPosition
  • Returns the position (in World Coordinates) where the object was hit by the ray

Type: 
  • float List [ x, y, z]

x:

  • x world coordinates
y:
  • y world coordinates
z:
  • z world coordinates
Ray Sensor:
  • Ray Sensor is triggered when the first game object is detected.
  • Ray Sensor is reset when all game objects are no longer detected.
  • Triggered:  One positive pulse is sent to the connected controller(s).
  • Reset:  One negative pulse is sent to the connected controller(s).
Sample Code


################  Find position where the object was hit by the ray  
 
# import bge module

import bge

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

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

sen = cont.sensors["Tripwire"]

# position where the object was hit by the ray
pos = sen.hitPosition