using variables of one controller in another+camera parenting

So…could anyone tell me how could i use variables of one controller in another controller
for example,
if i have two objects,one has a variable speed
now, if i wanted to use the same varialbe speed in another objects controller, what would i have to type in the script.

i also have a problem parenting a camera.
when i parented a camera to one object, it worked,but when i parented it to another one, it didnt work.it was parented, but the object that it was parented to, wasnt visible.

So…could anyone tell me how could i use variables of one controller in another controller
for example,
if i have two objects,one has a variable speed
now, if i wanted to use the same varialbe speed in another objects controller, what would i have to type in the script.
You can use:


own2 = GameLogic.getCurrentScene().getObjectList()["OBName"]
#Replace Name in "OBName" with the name of the object to which the
#the variable in question was originally assigned
#Then just call it as you would usually with own2
own2.thevariable

Or connect the python controller to one of the actuators of the object holding the variable and do:


own2 = cont.getActuator("actuatorname").getOwner()
own2.thevariable

Or you can use a global variable that can be accessed from anywhere “GameLogic.myvariable” I think.

i also have a problem parenting a camera.
when i parented a camera to one object, it worked,but when i parented it to another one, it didnt work.it was parented, but the object that it was parented to, wasnt visible.
Be more specific, or post the .blend.

thanks for helping
about the camera, i just used control p for parenting,no script.
and what happens is that the view moves with the object, but the object itself isnt visible, everything else is.

The problem is far too general, it could be a number of things.

Post the .blend.

My guess on your camera problem is either that the object’s center was behind the camera’s center, or that you scaled/zoomed the camera at some point in the process. Either of those two things could make your object not appear in the game.

Scaling the camera helped.Thanks