switch cams with one actuator

hey guys, i know this might sound like i;m doing things the hard way, but i’ve been trying to switch cameras via keyboard input but using only one actuator. The reason for this is that each camera is controlled by the mouse and behaves differently, therefore depending on what camera is active i have to establish the proper mouse interaction. I’m trying to use only one actuator because the only way (afaik) to find out witch camera is active is the getCamera() method inside the scene actuator.

here’s my script :

controler=GameLogic.getCurrentController()

topCam=controler.getSensor(“topCam”)
frontCam=controler.getSensor(“frontCam”)

camera = controler.getActuator(“camera”)

if topCam.isPositive() :
print “ne uitam prin camera de sus”
camera.setCamera(“OBtopCam”)

if frontCam.isPositive():
print “ne uitam prin camera frontala”
camera.setCamera(“OBfrontCam”)

and here’s my logic block setup :

globalControlls is an empty
the two keyboard sesnors listen for the one and two keys

and my problem is that this desn’t work, even if the console prints out the correct messages the cameras don’t switch

add:

camera.addActiveActuator()

at the bottom of the code (or at the end of both if parts)

edit :
still doesn’t work, my code looks like this now
controler=GameLogic.getCurrentController()

topCam=controler.getSensor(“topCam”)
frontCam=controler.getSensor(“frontCam”)

camera = controler.getActuator(“camera”)

if topCam.isPositive() :
print “ne uitam prin camera de sus”
camera.setCamera(“OBtopCam”)

if frontCam.isPositive():
print “ne uitam prin camera frontala”
camera.setCamera(“OBfrontCam”)

GameLogic.addActiveActuator(“camera”,1)

( addActiveActuator doesn’t seem to be a method for actuators :expressionless: so i used gamelogic)

You must put something in the OB: field in the camera actuator. It doesn’t work if it’s empty.

I think you need either 1 or True in the quotes, otherwise it won’t be active. Am I wrong?

You both are wrong. addActiveActuator() is a function of GameLogic. Pleaaaase… if you only barely know some python, don’t try and answer python questions, as you’re only going to confuse people.

rareseu, In your command, remove the quotes, so that it is GameLogic.addActiveActuator(camera,1). “camera” is just a String, which the addActiveActuator() does not take. If you know some stuff about Object Oriented programming, you can think of your camera variable as an actuator object. While cont.getActuator(String) takes a String argument (the name of the actuator), the addActiveActuator command’s arguments are an actuator object and a boolean object. (ie GameLogic.addActiveActuator(actuator, boolean) ).

note - in Python, 1 and 0 can be used as boolean, as well as (I believe) True, False, true, false.

-Sam

wops, sorry you are right. Strange mistake to make considering how many times I’ve used it.

true and false don’t work but True and False do, all though I find that when using a boolean property setting it to True and False don’t work, only setting it to 1 or 0 works.