Ray Sensor: hitNormal

hitNormal
  • Returns the normal as a 3D vector relative to the world coordinates

Type: 
  • float list [ nx, ny, nz]

nx: 

  • cosine of normal to world x-axis
ny: 
  • cosine of normal to world y-axis
nz: 
  • cosine of normal to 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 normal of the object face
 
# 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 normal of object face
face_normal = sen.hitNormal