new blender and python causes variable problems

Hey all,

I am upgrading my game code to the new blender 2.57 and python 3.2. The problem is that I did have

obj['startPosition'] = obj.position

and what used to happen was that this would take a snapshot if the objects position inside startPosition which I used to return the object to starting position after moving it around. Now what happens is it links the two so that when the objects position changes, it updates startPosition instantly and continuously.

so what do I need to do to get my snapshot and not link the two. This may have been answered already but I couldn’t think of a way to search for it, so I am asking.

Thanks a bunch

I see. If I recall, the problem is that the obj.position value used to be an array, but with 2.5, they’ve become objects of a class, meaning that obj[‘startposition’] = obj.position is just making a pointer to the obj.position object. You need to use

obj[‘startposition’] = obj.position.copy()

to make a complete copy of the position.

Awesome! Thanks SolarLune. I thought it might be something simple like that.