Camera: lens

lens
  • gets/sets the camera's focal length.

Type:
  • float number

Range:

  • 1.00 to 5000.00
Note:
  • The focal length of a lens determines its angle of view.
     
  • The focal length of a lens determines how much magnification it provides.
     
  • A lens with a shorter focal length will be able to "see" a wider view of a subject.
     
  • A lens with a longer focal length would see a narrower view of the scene but at a higher level of magnification.
Sample Code

################## get the camera's lens value
   

# 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 lens value
value = cam.lens

Sample Code

################## set the camera's lens value

# 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"]

# set the camera's lens to 35
cam.lens = 35.0