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$
12
$\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$
  • $\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$ – davidparks21 Nov 28 '17 at 19:44
3
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.