Camera setup, using python in blender 2.6

Hello guys, can someone please help me?
I need help setting different cameras at player, like in Silent Hill.

The diagram shows the mechanism:


If character collides with the T1 block, then set the camera depending on T1’s property called “cam_obj”. The same for T2.

Thanks in advance. :slight_smile:

Hi

python is not necessary , because if you want use a cube as collision you cannot using python which can simulate only a sphere.
anyway add two plane(static as default) with the right dimension and in the right space , a bit more hight respect to the ground
atttach to them:
2 sensors Collision(one for plane) (named T1 and T2 with a property “player”)(player have to be a property “player”)
attach this sensor to a python controller

add 2 cameras , name it camT1, and camT2 , put it in the right space and with the right direction/orientation and right zooms/lens.

the script:

####################

import bge

logic=bge.logic

scene=logic.getCurrentScene()
cont=logic.getCurrentController()

obs=scene.objects

camT1=obs[“camT1”]
camT2=obs[“camT2”]

sensT1=cont.sensors[“T1”]
sensT2=cont.sensors[“T2”]

if sensT1.positive : scene.active_camera = camT1
if sensT2.positive : scene.active_camera = camT2
#######################

moving the player on the two plane…

thanks, i’m just a beginner when it comes to python scripting, now i know how to do it :slight_smile:

well, if you have issue with python you can make that with a brick ,by activate directly the camera from a actuators “camera”
:wink:

yeah that’s what i currently use right now :smiley: