
getScreenRay(x, y, dist, prop)
- Looks towards a screen coordinate and returns the 1st game object hit with the property named and within the distance specified.
- KX_GameObject
or
- None (if didn't find a game object)
- x screen coordinate
- Type: float
- Range: 0.0 to 1.0
- y screen coordinate
- Type: float
- Range: 0.0 to 1.0
- maximum distance to look:
- uses negative distance to look behind
- 0.0 equals unlimited distance to look.
- Type: float
- property name to look for
- no property name equals look for all property names.
- Type: string
Note:
- [0.0, 0.0] is upper left corner of the game window.

Sample Code
################## Return the 1st game object hit with the property named
# import bge
import bge
# get current scene
scene = bge.logic.getCurrentScene()
# get a list of the cameras
camList = scene.cameras
# get camera
# my camera is named security_cam
cam = camList["security_cam"]
# get 1st object in center of game screen with property "Blue_Player"
obj = cam.getScreenRay(0.5, 0.5, 0.0, "Blue_Player")