Well afther learning some python I started slowly on learning Blender Python for creating games.
I know the basics and I did already some nice codes to move my character around and so on.
Now I’m stuck with something else, switching camera’s using the setCamera function.
My script looks like:
cont = GameLogic.getCurrentController()
own = cont.getOwner()
camera = cont.getActuator("camera")
pressone = cont.getSensor("one")
presstwo = cont.getSensor("two")
if pressone.isPositive():
own.cam = -1
elif presstwo.isPositive():
own.cam = 1
else:
own.cam = 0
if own.cam == -1:
camera.setCamera("camera1")
else:
camera.setCamera("camera2")
I already did a full setup of the: property: cam, keyboard sensors, and the Scene actuator that’s on set camera option.
When I press 1 or 2 I see the property changing in realtime using the “show debug properties” But it doesn’t do anything.
I also checked the camera names, and they are ok. I also tought about changing setCamera to getCamera, but that causes a blender crash.
I hope someone can help me.