Camera: getScreenVect

getScreenVect( x, y)
  • Returns the 3D vector from the camera position in the direction of the game screen coordinates.

Return Type:
  • list [vX, vY, vZ]  (3D vector)

x:
  • Type:  float  (x game screen coordinate)
  • Range:  0.0 to 1.0
y:
  • Type:  float  (y game screen coordinate)
  • Range:  0.0 to 1.0
Note:
  • [0.0, 0.0] is upper left corner of the game window.
Sample Code

################## Return the 3D vector from the camera position

# 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 3D vector to screen center
vec = cam.getScreenVect(0.5, 0.5)