3
$\begingroup$

Is it possible to do this in 2.6? I'm trying to dynamically create cameras. Looking around the API reference I found KX_Camera and Camera, but they have no constructors or factories, that work at least.

In 2.4 it seems that you could do it, as I believe they have .new() methods.

$\endgroup$
2
$\begingroup$

You could try this:

import bge

scene = bge.logic.getCurrentScene()
owner = bge.logic.getCurrentController().owner
cam = scene.addObject("Camera.001", owner , 0)

Note that the camera object needs to be on an inactive layer.

To set the active camera in the BGE:

bge.logic.getCurrentScene().active_camera = cam
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.