While in the blender game engine, I am trying to write a code that makes it so that the player changes the active camera every time the space-bar key is pressed. This is my first time making a game with blender so I apologize if this question is "annoying for advanced users" or how "noobs shouldn't be allowed to use blender". I'm sorry I'm still learning in advance, though thank you to whoever takes the time to help me. Here's my code:

#Code to switch between 2 camera: cam1 = Camera and cam2 = Camera.003
import bpy
import bge

bge = bge.logic()
cont = bge.logic.getCurrentController() 
own = cont.getOwner() 

context = bpy.context
scene = bge.logic.getCurrentScene()

    if evt.type == 'SPACE': #if space is pressed

        if scene.camera == bpy.data.objects["Camera"]: #and the scene camera is cam1
            print("on camera")
            scene.active_camera = bpy.data.objects["Camera.003"] #then switch to cam2

        elif scene.camera == bpy.data.objects["Camera.003"]: #or if current scene camera is cam2 and space key is pressed
            print("new scene camera")
            scene.active_camera = bpy.data.objects["Camera"] #switch to cam1

I keep getting the error 'module' object is not callable in the console. Here are my logic nodes:

enter image description here


locPoint = scene.objects['EmptyPanningEnd'].worldPosition
scene = logic.getCurrentScene()
cam1 = scene.objects['panningCamera']
cam2 = scene.objects['playerCamera']

if locPoint != cam1.worldPosition:
    scene.active_camera = cam1
    scene.active_camera = cam2```


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