i got a little problem with my code and was wondering if someone might have an answer to my question.
I’m trying to set properties to an object and delete them if I don’t need them anymore while a game is running.
If I set the properties and then start the game it all works fine. The only problem is the more complex my game gets the more properties my objects get and I’d like to avoid that.
I already tried something like this:
for key,status in sensor.events:
if status == STATUS_PRESSED and marple[‘sizeState’] == 0:
if key == bge.events.PAD1:
newProperty(‘StartSize’,‘FLOAT’)
newProperty(‘ScaleTimer’,‘TIMER’)
marple[‘ScaleTimer’] = 0
marple[‘StartSize’] = marple.localScale
marple[‘changeSize’] = True
break
Not sure what that ‘newProperty’ function call is, but if it’s part of bpy, you basically shouldn’t use that in the game engine. Redbaron is correct that declaring the property, accessing it like a dictionary on the object, is the way to go.
BTW: Your arguments why you want to remove properties sound really strange. You should never add properties which are not necessary. This way you never get “too much” of them.
If you really think you have to much (however you measure that), you better review the design of the logic and just one that fits better.