Ray Sensor: rayDirection

rayDirection
  • Returns the direction (in World Coordinates) that the ray is pointing

Type: 
  • float List [ dx, dy, dz ]

dx:

  • cosine of the vector to the world x-axis
dy:
  • cosine of the vector to the world y-axis
    dz:
    • cosine of the vector to the world z-axis
    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 direction the ray is pointing.

    # 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 ray direction
    direction_ray = sen.rayDirection