Get Game Property of an Object

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
zoltinho
Posts: 0
Joined: Wed Jan 18, 2012 2:24 pm

Get Game Property of an Object

Post by zoltinho » Wed Jan 18, 2012 2:33 pm

Hi all!

On object A I have a property sensor which triggers a script. I need this script to be triggered once the scene is completely loaded and ready for user interaction, therefore I decided to make an 'always' sensor on the game camera, which would set the property, thus triggering the sensor on object A.

My problem is that I can't find a way to access any of the game properties defined for object A from the game camera, so I can't trigger the property sensor.

If object A was the owner of the script that changes the property, I could do

Code: Select all

cont = bge.logic.getCurrentController()
own = cont.owner
own['property'] = 1
But that's not the case. I tried fetching object A using

Code: Select all

bpy.data.objects['A']
but this does not give me access to its game properties.

Is there another way to access object A's game properties?

mb
Posts: 0
Joined: Mon Feb 22, 2010 10:20 am

Post by mb » Wed Jan 18, 2012 3:20 pm

Try to access the object by its name, rather than as the "owner" of the controller, i.e.:

Code: Select all

obj = bge.logic.getCurrentScene().objects['ObjectA']
obj['property'] = 1
mb

Post Reply