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:
2 Answers
$\begingroup$
$\endgroup$
1
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']
-
$\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$ Commented Nov 28, 2017 at 19:44
$\begingroup$
$\endgroup$
0
Your question is a bit unclear, but you can use use own['propName']
to access a property