Hi!
I have this python code, connected with always-true sensor:
#I declared PB before, ignore it
for o in own ["PB"]:
if 'pos' not in o:
o['pos'] = o.worldPosition
for o in own ["PB"]:
o.worldPosition = [10,10,10]
for o in own ["PB"]:
o.worldPosition = o['pos']
Which you would think the final result of the o.worldPosition is o[‘pos’] of the first one right?
BUT, it isnt!
the final o.worldPosition is 10,10,10 and NOT the first o[‘pos’] one!!
Yeah seems like you have a problem of references here (you’re not creating a new position, you’re referencing it). So to solve it just use copy(). It’s not a bug by the way.
#I declared PB before, ignore it
for o in own ["PB"]:
if 'pos' not in o:
o['pos'] = o.worldPosition.copy()
for o in own ["PB"]:
o.worldPosition = [10,10,10]
for o in own ["PB"]:
o.worldPosition = o['pos']