Ray Sensor: range

range
  • gets/sets the Range of the ray

Type: 
  • float number

Range:

  • 0.01 to 10000.00
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


################  Get the Range of 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"]

# get the range of the ray
distance = sen.range
 
Sample Code


################  Set the Range of 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"]

# Set the distance of the ray
sen.range = 10.00