| Class KX_RaySensor (2.48) |
|
|
| getHitNormal |
getHitPosition |
| getHitObject |
getRayDirection |
|
|
|
| getFrequency |
reset |
| getInvert |
setFrequency |
| getLevel |
setInvert |
| getUseNegPulseMode |
setLevel |
| getUsePosPulseMode |
setUseNegPulseMode |
| isPositive |
setUsePosPulseMode |
| isTriggered |
---------- |
|
|
|
| getExecutePriority |
setExecutePriority |
| getOwner |
---------- |
|
|
getHitNormal
getHitNormal()
Returns the normal (in world coordinates) where the object was hit by
the ray.
Return type: List [ nx, ny, nz]
nx = cosine of the normal to the world x-axis
Type: float
ny = cosine of the normal to the world y-axis
Type: float
nz = cosine of the normal to the world z-axis
Type: float
Sample
Code
# get the controller
controller = GameLogic.getCurrentController()
# get the ray sensor attached to the controller named
GuardDuty
ray = controller.getSensor("GuardDuty")
# get the normal of object where it was hit
norm = ray.getHitNormal()
getHitObject
getHitObject()
Returns the game object that was hit by this ray.
Return type: KX_GameObject
Sample
Code
# get the controller
controller = GameLogic.getCurrentController()
# get the ray sensor attached to the controller named
GuardDuty
ray = controller.getSensor("GuardDuty")
# get the game object hit by ray
gameObj = ray.getHitObject()
# get the name of game object
name = gameObj.getName()
getHitPosition
getHitPosition()
Returns the position (in World Coordinates) where the object was hit by
the ray.
Return type: List [ x, y, z]
x = position world
x-axis
Type:
float
y = position world y-axis
Type:
float
z = position world z-axis
Type: float
Sample
Code
# get the controller
controller = GameLogic.getCurrentController()
# get the ray sensor attached to the controller named
GuardDuty
ray = controller.getSensor("GuardDuty")
# get position where the game object hit by ray
pos = ray.getHitPosition()
getRayDirection
getRayDirection()
Returns the direction (in World Coordinates) that the ray is pointing.
Return type: List [ dx, dy, dz]
dx = cosine of the
direction vector to the world x-axis
Type:
float
dy = cosine of the direction vector to the world y-axis
Type:
float
dz = cosine of the direction vector to the world z-axis
Type:
float
Sample
Code
# get the controller
controller = GameLogic.getCurrentController()
# get the ray sensor attached to the controller named
GuardDuty
ray = controller.getSensor("GuardDuty")
# get direction Ray is pointing
dir = ray.getRayDirection()
|