13
$\begingroup$

I would like to know how to change the values of properties added using the "AddGameProperty" option in the game logic UI using python code? I want to write code that changes the 'Property' value in an Action Actuator logic block. I attached a screenshot for a bit more clarity: How do you change the game properties value to control the action actuator using python code??

$\endgroup$

2 Answers 2

13
$\begingroup$

If you want to access a property from the current object controller it's :

cont = bge.logic.getCurrentController()
own = cont.owner
my_property=own['propName']

But if you want to access to a property from an other object it's

scene = bge.logic.getCurrentScene()
my_property=scene.objects['other object']['otherpropName']
$\endgroup$
1
  • $\begingroup$ When I get the property using scene it shows only the default property, I don't get the current value of the property which changes as the game progresses. $\endgroup$ Nov 28, 2017 at 19:44
3
$\begingroup$

Your question is a bit unclear, but you can use use own['propName'] to access a property

$\endgroup$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .