Scene: active_camera

active_camera
  • gets/sets the active camera.

Type:

  • KX_Camera
Note:
  • The active camera is the camera being used to render the game window.
Sample Code

################## get the active camera
 
# import bge
import bge

# get current scene
scene = bge.logic.getCurrentScene()

# get the active camera
cam = scene.active_camera

Sample Code

################## set the active camera
 
# import bge
import bge

# get current scene
scene = bge.logic.getCurrentScene()

# get a list of the cameras in the scene
camList = scene.cameras

# get camera named SecurityCam
cam = camList["SecurityCam"]

# set the active camera
scene.active_camera = cam